Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jan 4, 2025
1 parent aedfdcc commit 83b8ff8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions routes/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function(req, res, next){
res.set('Cache-Control', `public, max-age=60, stale-while-revalidate=${cdn_cache}`);

if(doc){
const revision = 2;
const revision = 2; // bump to invalidate all caches
const etag = `W/"${doc._id}${revision}"`;
const date = new Date(doc._published.getTime() + revision * 1000).toUTCString();
res.set('ETag', etag);
Expand All @@ -43,7 +43,6 @@ export default function(req, res, next){
//revalidation can either be done by comparing Etag or Last-Modified.
//do not set 'must-revalidate' as this will disallow using stale cache when server is offline.
if(etag === req.header('If-None-Match') || date === req.header('If-Modified-Since')){
//todo: also invalidate for updates in frontend itself?
res.status(304).send();
} else {
next(); //proceed to routing
Expand Down

0 comments on commit 83b8ff8

Please sign in to comment.