diff --git a/docs/functions/[[path]].ts b/docs/functions/[[path]].ts index 554ef48a7ac..2a7424170bf 100644 --- a/docs/functions/[[path]].ts +++ b/docs/functions/[[path]].ts @@ -14,7 +14,20 @@ export const onRequestGet: PagesFunction = async ({ request, next, waitUntil }) } if (/\.\w+$/.test(url.pathname)) { - return next(request); + const response = await next(request); + + if (url.pathname.startsWith('/q-')) { + // assets starting with `q-` we know can be forever cached + // current workaround until this is merged: https://github.com/cloudflare/wrangler2/pull/796 + const headers = new Headers(); + response.headers.forEach((value, key) => headers.set(key, value)); + headers.set('Cache-Control', 'public, max-age=31536000, immutable'); + return new Response([101, 204, 205, 304].includes(response.status) ? null : response.body, { + ...response, + headers, + }); + } + return response; } // do not using caching during development @@ -31,7 +44,7 @@ export const onRequestGet: PagesFunction = async ({ request, next, waitUntil }) // Generate Qwik SSR response const ssrResult = await render({ - url: new URL(request.url), + url: request.url, symbols, base: '/', });