keldaanCommunity / pokemonAutoChess

Pokemon Auto Chess Game. Made by fans for fans. Open source, non profit. All rights to the Pokemon Company.
https://pokemon-auto-chess.com/
GNU General Public License v3.0
347 stars 217 forks source link

cache busting for translations files #2207

Closed sylvainpolletvillard closed 18 hours ago

sylvainpolletvillard commented 1 week ago

Try to fix the cache issue with translations file on patch release. No more Ctrl+F5 !

At first i tried to do filename hash suffix with esbuild like what we do for index.js and index.css, but it ends up being quite complicated. esbuild is not really the tool for that.

I made hash generation based on file content with one hash specific to each translation file, but then the problem was to decide where to store those hashes in order for i18next to load them properly. Storing these hashes in a global variable or concatenating a variable declaration in the built index.js file was pretty ugly to me, so instead i decided to use the hash from index.js to suffix all translations. My reasoning is that the main index.js file will be very likely updated every time we ship a hotfix and need people to reload translations. I know its not perfect, for example we'll still have the cache if we deliver exclusively a translation hotfix without touching at the source.

Another option is to rely on service worker exclusively to cache these translation files, and remove all cache headers from server for those files. It's much simpler but also force to change version of service worker every time we touch at translations, redownloading all assets.

keldaan-ag commented 1 week ago

we can give this a try

sylvainpolletvillard commented 18 hours ago

closing in favor of https://github.com/keldaanCommunity/pokemonAutoChess/pull/2235