Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/functions/[[path]].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: '/',
});
Expand Down