1
0
mirror of synced 2025-12-20 10:28:40 -05:00

Combine cache control (#33067)

This commit is contained in:
Kevin Heis
2022-11-29 16:04:34 -08:00
committed by GitHub
parent 9cd9f87df2
commit f161f86ca1
11 changed files with 25 additions and 45 deletions

View File

@@ -8,13 +8,6 @@
// cacheControlYear(res)
// res.send(body)
//
// Or, if you want to make it definitely not cache:
//
// const noCacheControl = getCacheControl(0) // you can use `false` too
// ...
// noControlYear(res)
// res.send(body)
//
// Max age is in seconds
export function cacheControlFactory(
maxAge = 60 * 60,
@@ -56,3 +49,9 @@ export function defaultCacheControl(res) {
defaultCDNCacheControl(res)
defaultBrowserCacheControl(res)
}
// If you do not want caching
export const noCacheControl = cacheControlFactory(0)
// Long caching for archived pages and assets
export const archivedCacheControl = cacheControlFactory(60 * 60 * 24 * 365)