Permalink
Browse files

Limit CDN max-age to 24 hours for files on the master branch.

Because I'm sick of manually purging files from the CDN when someone
screws up and begs me to fix their mistake for them on Christmas
morning.
  • Loading branch information...
1 parent f13b9f7 commit 2ad0621751bd062df68b9df1c081bf7bf58b47b5 @rgrove committed Jan 2, 2017
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/middleware/proxy-path.js
@@ -133,7 +133,11 @@ function onResponse(req, res, upstreamResponse) {
// Stream 200 responses with the correct Content-Type.
if (upstreamStatus === 200) {
if (req.isCDN) {
+ if (req.params.branch === 'master') {
+ res.set('Cache-Control', 'max-age=86400'); // 24 hours
+ } else {
res.set('Cache-Control', 'max-age=315569000, immutable'); // 10 years
+ }
} else {
// Tell browsers to cache for an hour, CDNs to cache for 5 minutes.
res.set('Cache-Control', 'max-age=3600, s-maxage=300');

0 comments on commit 2ad0621

Please sign in to comment.