Compare commits

...

1 Commits

Author SHA1 Message Date
Samy Pessé 0a4c3a98ea Set cache-control to no-cache for adaptive content 2024-12-20 23:22:22 +01:00
+4 -4
View File
@@ -290,8 +290,10 @@ export async function middleware(request: NextRequest) {
setMiddlewareHeader(response, 'referrer-policy', 'no-referrer-when-downgrade'); setMiddlewareHeader(response, 'referrer-policy', 'no-referrer-when-downgrade');
setMiddlewareHeader(response, 'x-content-type-options', 'nosniff'); setMiddlewareHeader(response, 'x-content-type-options', 'nosniff');
if (typeof resolved.cacheMaxAge === 'number') { const cacheControl =
const cacheControl = `public, max-age=0, s-maxage=${resolved.cacheMaxAge}, stale-if-error=0`; typeof resolved.cacheMaxAge === 'number'
? `public, max-age=0, s-maxage=${resolved.cacheMaxAge}, stale-if-error=0`
: 'no-cache';
if (process.env.GITBOOK_OUTPUT_CACHE === 'true' && process.env.NODE_ENV !== 'development') { if (process.env.GITBOOK_OUTPUT_CACHE === 'true' && process.env.NODE_ENV !== 'development') {
setMiddlewareHeader(response, 'cache-control', cacheControl); setMiddlewareHeader(response, 'cache-control', cacheControl);
@@ -299,8 +301,6 @@ export async function middleware(request: NextRequest) {
} else { } else {
setMiddlewareHeader(response, 'x-gitbook-cache-control', cacheControl); setMiddlewareHeader(response, 'x-gitbook-cache-control', cacheControl);
} }
}
// }
if (resolved.cacheTags && resolved.cacheTags.length > 0) { if (resolved.cacheTags && resolved.cacheTags.length > 0) {
const headerCacheTag = resolved.cacheTags.join(','); const headerCacheTag = resolved.cacheTags.join(',');