I am maintaining a Restify server using a static content plugin. The plugin imposes a Cache-Control
header despite anything that happened beforehand. max-age
is always included, and defaults to 3600.
Cache-Control: public, max-age=3600
I need to have a large max-age
for everything except index.html
.
server.pre((req, res, next) => {
const path = url.parse(req.url);
if (path.pathname === '/' && req.accepts('text/html')) {
req.url = '/public/index.html';
// Encourage the client to always download index.html.
res.header('Expires', '0');
res.header('Cache-Control',
'no-store, no-cache, must-revalidate, max-age=0');
}
next();
});
The problem is that the static server's forced addition of Cache-Control
causes the server to send contradictory max-age
values.
Cache-Control:no-store, no-cache, must-revalidate, max-age=0
Cache-Control:public, max-age=315360000
I tried something to stop this that did not work, but is this even an issue? I don't know if browsers will resolve the contradiction by downloading index.html
fresh (which is what I want)