@@ -13,10 +13,7 @@ import cookieParser from './cookie-parser.js'
13
13
import csrf from './csrf.js'
14
14
import handleCsrfErrors from './handle-csrf-errors.js'
15
15
import 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'
20
17
import setFastlyCacheHeaders from './set-fastly-cache-headers.js'
21
18
import catchBadAcceptLanguage from './catch-bad-accept-language.js'
22
19
import reqUtils from './req-utils.js'
@@ -63,6 +60,7 @@ import renderPage from './render-page.js'
63
60
import assetPreprocessing from './asset-preprocessing.js'
64
61
import archivedAssetRedirects from './archived-asset-redirects.js'
65
62
import favicon from './favicon.js'
63
+ import setStaticAssetCaching from './static-asset-caching.js'
66
64
67
65
const { DEPLOYMENT_ENV , NODE_ENV } = process . env
68
66
const isDevelopment = NODE_ENV === 'development'
@@ -115,14 +113,16 @@ export default function (app) {
115
113
116
114
app . use ( favicon )
117
115
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
123
123
// the `assetPreprocessing` middleware will rewrite `req.url` if
124
124
// it applies.
125
- app . use ( setManualFastlySurrogateKeyIfChecksummed )
125
+ app . use ( setStaticAssetCaching )
126
126
127
127
// Must come before any other middleware for assets
128
128
app . use ( archivedAssetRedirects )
0 commit comments