From 0a9ed4f3bc9a9299926b26f1c7b387bd5a48f215 Mon Sep 17 00:00:00 2001 From: Grant Marvin Date: Sat, 26 Oct 2024 20:17:07 -0500 Subject: [PATCH] Proxy Cache-Control header (#923) * Proxy Cache-Control header I was running into an issue where refreshing an extension page would load stale code. This happened because without the cache-control header, refreshing would use the cached version of index.html. Vite already sets the header appropriately, so we just need to pass it down through the service worker. * Add changeset --------- Co-authored-by: Jack Steam --- .changeset/chatty-teachers-compare.md | 5 +++++ packages/vite-plugin/src/client/es/hmr-client-worker.ts | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/chatty-teachers-compare.md diff --git a/.changeset/chatty-teachers-compare.md b/.changeset/chatty-teachers-compare.md new file mode 100644 index 000000000..99298fe98 --- /dev/null +++ b/.changeset/chatty-teachers-compare.md @@ -0,0 +1,5 @@ +--- +"@crxjs/vite-plugin": patch +--- + +Proxy Cache-Control header diff --git a/packages/vite-plugin/src/client/es/hmr-client-worker.ts b/packages/vite-plugin/src/client/es/hmr-client-worker.ts index 2a0f4020e..de056f92a 100644 --- a/packages/vite-plugin/src/client/es/hmr-client-worker.ts +++ b/packages/vite-plugin/src/client/es/hmr-client-worker.ts @@ -46,6 +46,7 @@ async function sendToServer(url: URL): Promise { return new Response(response.body, { headers: { 'Content-Type': response.headers.get('Content-Type') ?? 'text/javascript', + 'Cache-Control': response.headers.get('Cache-Control') ?? '', }, }) }