* Middleware overhaul! - Remove unnecessary 'async' keywords from middleware functions - Ensure all middleware functions we create have names - Wrap the method contents of all async middleware functions in a try-catch+next(error) pattern * Use asyncMiddleware wrapper instead of try-catch+next(error) pattern * Remove unnecessary try-catch+next(error) pattern from context middleware
13 lines
620 B
JavaScript
13 lines
620 B
JavaScript
module.exports = function setFastlySurrogateKey (req, res, next) {
|
|
// Fastly provides a Soft Purge feature that allows you to mark content as outdated (stale) instead of permanently
|
|
// purging and thereby deleting it from Fastly's caches. Objects invalidated with Soft Purge will be treated as
|
|
// outdated (stale) while Fastly fetches a new version from origin.
|
|
//
|
|
// Use of a surrogate key is required for soft purging
|
|
// https://docs.fastly.com/en/guides/soft-purges
|
|
// https://docs.fastly.com/en/guides/getting-started-with-surrogate-keys
|
|
res.set('surrogate-key', 'all-the-things')
|
|
|
|
return next()
|
|
}
|