From cad6cfd5a705d412a23c880deefee8883626581b Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Tue, 23 Apr 2024 10:39:22 -0400 Subject: [PATCH] Play more nicely with server caches Let's stop sending cookies by default with requests for static files. The presence of cookies causes our new host to abort caching static files at the edge. And this can cause the same issue with other caches as well. --- .../web-service-worker/src/initialize-service-worker.ts | 2 ++ packages/playground/remote/service-worker.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/php-wasm/web-service-worker/src/initialize-service-worker.ts b/packages/php-wasm/web-service-worker/src/initialize-service-worker.ts index c36af3ecbc..b104e9dd03 100644 --- a/packages/php-wasm/web-service-worker/src/initialize-service-worker.ts +++ b/packages/php-wasm/web-service-worker/src/initialize-service-worker.ts @@ -57,6 +57,8 @@ async function defaultRequestHandler(event: FetchEvent) { ) { const request = await cloneRequest(event.request, { url, + // Omit credentials to avoid causing cache aborts due to presence of cookies + credentials: 'omit', }); return fetch(request); } diff --git a/packages/playground/remote/service-worker.ts b/packages/playground/remote/service-worker.ts index 32fc115201..86d67abda9 100644 --- a/packages/playground/remote/service-worker.ts +++ b/packages/playground/remote/service-worker.ts @@ -73,6 +73,8 @@ initializeServiceWorker({ } const request = await cloneRequest(event.request, { url: resolvedUrl, + // Omit credentials to avoid causing cache aborts due to presence of cookies + credentials: 'omit', }); return fetch(request).catch((e) => { if (e?.name === 'TypeError') {