Skip to content

Commit

Permalink
Proxy Cache-Control header (#923)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
rogueg and jacksteamdev authored Oct 27, 2024
1 parent 746c9a7 commit 0a9ed4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-teachers-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@crxjs/vite-plugin": patch
---

Proxy Cache-Control header
1 change: 1 addition & 0 deletions packages/vite-plugin/src/client/es/hmr-client-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async function sendToServer(url: URL): Promise<Response> {
return new Response(response.body, {
headers: {
'Content-Type': response.headers.get('Content-Type') ?? 'text/javascript',
'Cache-Control': response.headers.get('Cache-Control') ?? '',
},
})
}
Expand Down

0 comments on commit 0a9ed4f

Please sign in to comment.