Skip to content

Commit

Permalink
Don't cache VA and adaptive content responses (#2663)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse authored Dec 27, 2024
1 parent 72c3b80 commit 2f6540e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/gitbook/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ export async function middleware(request: NextRequest) {
setMiddlewareHeader(response, 'referrer-policy', 'no-referrer-when-downgrade');
setMiddlewareHeader(response, 'x-content-type-options', 'nosniff');

if (typeof resolved.cacheMaxAge === 'number') {
if (
typeof resolved.cacheMaxAge === 'number' &&
// When the request is authenticated, we don't want to cache the response on the server
!resolved.visitorToken
) {
const cacheControl = `public, max-age=0, s-maxage=${resolved.cacheMaxAge}, stale-if-error=0`;

if (process.env.GITBOOK_OUTPUT_CACHE === 'true' && process.env.NODE_ENV !== 'development') {
Expand Down

0 comments on commit 2f6540e

Please sign in to comment.