To send no cache headers in Node.js server, we call the writeHead
method.
For instance, we write
res.writeHead(200, {
"Content-Type": mimeType,
"Content-Length": contents.length,
"Accept-Ranges": "bytes",
"Cache-Control": "no-cache",
});
to call writHeader
with an object with the response headers and values.
We return the Content-Type
, Content-Length
, Accept-Ranges
, and Cache-Control
headers.
We set Cache-Control
to no-cache
to disable cache.