Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: don't use stale-while-revalidate for loaders
the browser doesn't have a way to notify you when it updated.
  • Loading branch information
wmertens committed Sep 21, 2025
commit 7ec1b9fbaabb7b61d63240713e99e668437d4525
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export function loaderHandler(routeLoaders: LoaderInternal[]): RequestHandler {
// Set cache headers - aggressive for loaders
requestEv.cacheControl({
maxAge: 300, // 5 minutes
staleWhileRevalidate: 3600, // 1 hour
});

const data = await _serialize([loaders[loaderId]]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export async function qDataHandler(requestEv: RequestEvent) {

// Set cache headers
requestEv.cacheControl({
maxAge: 300, // 5 minutes
staleWhileRevalidate: 3600, // 1 hour
maxAge: 60, // 1 minute
});

// write just the page json data to the response body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ export interface CacheControlOptions {
/**
* The stale-while-revalidate response directive indicates that the cache could reuse a stale
* response while it revalidates it to a cache.
*
* Note: there is no mechanism that updates the application when the revalidation happens. Use
* this only when you know you will be fetching the revalidated resource again in the very near
* future.
*/
staleWhileRevalidate?: number;

Expand Down