Skip to content

Commit

Permalink
fix: finetune cache write condition
Browse files Browse the repository at this point in the history
  • Loading branch information
esroyo committed Feb 22, 2024
1 parent a37ddca commit 35ce0f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ export const createFinalResponse = async (
if (!headers.has('access-control-allow-origin')) {
headers.set('access-control-allow-origin', '*');
}
const isActualRedirect = isRedirect(status);
const isActualRedirect = isRedirect(status) && !isFastPathRedirect;
const isCacheable = isOk(status) || isActualRedirect;
const willCache = shouldCache && isCacheable;
if (willCache) {
performance.mark('cache-write');
await saveCache(denoKv, [url, buildTarget], responseProps);
performance.measure('cache-write', 'cache-write');
headers.set('x-debug-cache-key', JSON.stringify([url, buildTarget]));
}
const shouldSetCacheClientRedirect = CACHE_CLIENT_REDIRECT &&
isFastPathRedirect;
Expand Down

0 comments on commit 35ce0f4

Please # to comment.