BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
12.97k stars 427 forks source link

[✨] `lib` files cache busting? #439

Open aradalvand opened 1 year ago

aradalvand commented 1 year ago

Is your feature request related to a problem?

Currently, the lib files are supposed to be directly served as static files; and static files of this sort are usually cached by the browser. If changes are made to one of these files in a future Partytown update, you'd ideally want the browsers that have previously downloaded and cached these files to invalidate their cache and download the new versions.

This is usually achieved by appending a hash to the filenames. I'm using SvelteKit and it does have that kind of capability (thanks to Vite), but Partytown currently doesn't take advantage of it.

Describe the solution you'd like

I'm just curious whether this issue has been thought about before.

Describe alternatives you've considered

N/A

Additional context

No response

mhevery commented 1 year ago

The cache-header controls the caching of files; therefore, you can specify the duration. I don't see a reason to change the serving strategy.

aradalvand commented 1 year ago

Usually the Cache-Control header specifies the longest possible duration (typically 2 years) for CSS, JS assets and so on, so that the files are cached until a new version has been created and the old ones have to be busted (which is then accomplished by changing the name of the file), this is how modern frameworks like SvelteKit, Next.js, Nuxt, etc. work.

Why wouldn't Partydown take advantage of the same mechanism?!