@@ -13,10 +13,7 @@ import cookieParser from './cookie-parser.js'
1313import csrf from './csrf.js'
1414import handleCsrfErrors from './handle-csrf-errors.js'
1515import compression from 'compression'
16- import {
17- setDefaultFastlySurrogateKey ,
18- setManualFastlySurrogateKeyIfChecksummed ,
19- } from './set-fastly-surrogate-key.js'
16+ import { setDefaultFastlySurrogateKey } from './set-fastly-surrogate-key.js'
2017import setFastlyCacheHeaders from './set-fastly-cache-headers.js'
2118import catchBadAcceptLanguage from './catch-bad-accept-language.js'
2219import reqUtils from './req-utils.js'
@@ -63,6 +60,7 @@ import renderPage from './render-page.js'
6360import assetPreprocessing from './asset-preprocessing.js'
6461import archivedAssetRedirects from './archived-asset-redirects.js'
6562import favicon from './favicon.js'
63+ import setStaticAssetCaching from './static-asset-caching.js'
6664
6765const { DEPLOYMENT_ENV , NODE_ENV } = process . env
6866const isDevelopment = NODE_ENV === 'development'
@@ -115,14 +113,16 @@ export default function (app) {
115113
116114 app . use ( favicon )
117115
118- // Any `/assets/cb-*` request should get the setManualFastlySurrogateKey()
119- // middleware, but it's not possible to express such a prefix in
120- // Express middlewares. Because we don't want the manual Fastly
121- // surrogate key on *all* /assets/ requests.
122- // Note, this needs to come before `assetPreprocessing` because
116+ // Any static URL that contains some sort of checksum that makes it
117+ // unique gets the "manual" surrogate key. If it's checksummed,
118+ // it's bound to change when it needs to change. Otherwise,
119+ // we want to make sure it doesn't need to be purged just because
120+ // there's a production deploy.
121+ // Note, for `/assets/cb-*...` requests,
122+ // this needs to come before `assetPreprocessing` because
123123 // the `assetPreprocessing` middleware will rewrite `req.url` if
124124 // it applies.
125- app . use ( setManualFastlySurrogateKeyIfChecksummed )
125+ app . use ( setStaticAssetCaching )
126126
127127 // Must come before any other middleware for assets
128128 app . use ( archivedAssetRedirects )
0 commit comments