Cache Busting for Static Assets #4745
-
When deploying new versions of modules in a production environment, you might end up with updated code but obsolete css or js due to browser cache (at least in static mode), which is really problematic as the user will perceive a broken site (i.e major css changes or new sections whose css is not served). Does Oqtane have any cache busting system or something similar to prevent this issue? Usual techniques like bundlers do not work properly here because you need to reference the static assets in the ModuleInfo. It would be nice if Oqtane had some way to achieve this easily. For example, on build time (perhaps only on release mode?), computing the hash of static assets and appending it to the resource declaration. In this way, when deploying an updated module, the hash of the modified assets would change and the browser would request them as if they were new. This effectively keeps the unmodifed files cached, and requests the modified ones to avoid the "broken" site state. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
As a developer of a module, you obviously know when one of your static dependencies has changed ie. a CSS or JavaScript file. If you want to ensure that it gets reloaded you can append a querystring to the Resource reference in your code:
This approach works well and is much more efficient than imposing a large overheard on the framework itself to compute and manage versions for every static asset - including those that rarely/never change. |
Beta Was this translation helpful? Give feedback.
-
@sbwalker will it be possible to use the new capabilites of .NET 9 like Fingerprinting (presented here: https://youtu.be/o0CWssf8TFw?si=43WJp4HDqoREiIPl&t=2550) in Oqtane respectively Oqtane modules? |
Beta Was this translation helpful? Give feedback.
As a developer of a module, you obviously know when one of your static dependencies has changed ie. a CSS or JavaScript file. If you want to ensure that it gets reloaded you can append a querystring to the Resource reference in your code:
This approach works well and is much more efficient than imposing a large overheard on the framework itself to compute and manage versions for every static asset - including those that rarely/never change.