cache asset images more aggressively (#23553)
* cache asset images more aggressively * more careful about which gets the manual surrogate key * fix rendered-content-link-checker script too * feedbacked
This commit is contained in:
@@ -14,7 +14,10 @@ import csrf from './csrf.js'
|
||||
import handleCsrfErrors from './handle-csrf-errors.js'
|
||||
import compression from 'compression'
|
||||
import disableCachingOnSafari from './disable-caching-on-safari.js'
|
||||
import setDefaultFastlySurrogateKey from './set-fastly-surrogate-key.js'
|
||||
import {
|
||||
setDefaultFastlySurrogateKey,
|
||||
setManualFastlySurrogateKey,
|
||||
} from './set-fastly-surrogate-key.js'
|
||||
import setFastlyCacheHeaders from './set-fastly-cache-headers.js'
|
||||
import catchBadAcceptLanguage from './catch-bad-accept-language.js'
|
||||
import reqUtils from './req-utils.js'
|
||||
@@ -57,6 +60,7 @@ import featuredLinks from './featured-links.js'
|
||||
import learningTrack from './learning-track.js'
|
||||
import next from './next.js'
|
||||
import renderPage from './render-page.js'
|
||||
import assetPreprocessing from './asset-preprocessing.js'
|
||||
|
||||
const { NODE_ENV } = process.env
|
||||
const isDevelopment = NODE_ENV === 'development'
|
||||
@@ -95,17 +99,25 @@ export default function (app) {
|
||||
instrument(archivedEnterpriseVersionsAssets, './archived-enterprise-versions-assets')
|
||||
)
|
||||
)
|
||||
// This must come before the express.static('assets') middleware.
|
||||
app.use(assetPreprocessing)
|
||||
// By specifying '/assets/cb-' and not just '/assets/' we
|
||||
// avoid possibly legacy enterprise assets URLs and asset image URLs
|
||||
// that don't have the cache-busting piece in it.
|
||||
app.use('/assets/cb-', setManualFastlySurrogateKey)
|
||||
app.use(
|
||||
'/assets',
|
||||
'/assets/',
|
||||
express.static('assets', {
|
||||
index: false,
|
||||
etag: false,
|
||||
lastModified: false,
|
||||
maxAge: '1 day', // Relatively short in case we update images
|
||||
// Can be aggressive because images inside the content get unique
|
||||
// URLs with a cache busting prefix.
|
||||
maxAge: '7 days',
|
||||
})
|
||||
)
|
||||
app.use(
|
||||
'/public',
|
||||
'/public/',
|
||||
express.static('data/graphql', {
|
||||
index: false,
|
||||
etag: false,
|
||||
|
||||
Reference in New Issue
Block a user