ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
750 stars 113 forks source link

Is there a way to do cache busting by languageCode? #277

Open mrsuau627 opened 1 year ago

mrsuau627 commented 1 year ago

We're in the process of converting a .NET Framework 4.7.2 Asp.NET application to .NET Core 6. In the .NET Framework app, we were using a language translation package by turquoiseowl that worked pretty well: https://github.com/turquoiseowl/i18n. We used the standard BundleConfig method of doing our package bundling and there were cases where the translations were done in the js file and then served up to the client. Because of this, with this older solution, we would append "?lang={languageCode}" to the bundle so that when a user switched languages, it would know it needed a different js bundle for that particular language, rather than grabbing the cached one.

For .NET Core, we're using a package very similar to this to do the translations. We're using WebOptimizer for js/css/html bundling and we'd like to do something similar. Right now, in order for cache busting to work, WebOptimizer generates a 'v={some long hash}" query param that it adds to each bundle so that it knows when it needs to refresh the cached bundles. Is there a way to add to this version or affect it in some way using the selected language tag? For example, a user is in spanish, generate a js bundle that looks like ?v=w8i38383je838d9jdf9df9ie&lang=es. Then an English user logs in, their bundle might be ?v=w8i38383je838d9jdf9df9ie&lang=en-us.

Thanks in advance