Skip to content

Commit 54bfae0

Browse files
committed
fix: don't use stale-while-revalidate for loaders
the browser doesn't have a way to notify you when it updated.
1 parent 29ba38a commit 54bfae0

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

packages/qwik-router/src/middleware/request-handler/handlers/loader-handler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export function loaderHandler(routeLoaders: LoaderInternal[]): RequestHandler {
108108
// Set cache headers - aggressive for loaders
109109
requestEv.cacheControl({
110110
maxAge: 300, // 5 minutes
111-
staleWhileRevalidate: 3600, // 1 hour
112111
});
113112

114113
const data = await _serialize([loaders[loaderId]]);

packages/qwik-router/src/middleware/request-handler/handlers/qdata-handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export async function qDataHandler(requestEv: RequestEvent) {
3232

3333
// Set cache headers
3434
requestEv.cacheControl({
35-
maxAge: 300, // 5 minutes
36-
staleWhileRevalidate: 3600, // 1 hour
35+
maxAge: 60, // 1 minute
3736
});
3837

3938
// write just the page json data to the response body

packages/qwik-router/src/middleware/request-handler/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ export interface CacheControlOptions {
399399
/**
400400
* The stale-while-revalidate response directive indicates that the cache could reuse a stale
401401
* response while it revalidates it to a cache.
402+
*
403+
* Note: there is no mechanism that updates the application when the revalidation happens. Use
404+
* this only when you know you will be fetching the revalidated resource again in the very near
405+
* future.
402406
*/
403407
staleWhileRevalidate?: number;
404408

0 commit comments

Comments
 (0)