Feature #2299
Ability to invalidate browser caches with version updates
90%
Associated revisions
Adding versioning of the CSS and JS files
Reference #2299
Adding cache busting for the JS and templates
Closes #2299
JS now uses a variable to help with cache busting
Reference #2299
History
#1 Updated by Luke Murphey about 6 years ago
We can load the VERSION info with this:
try:
version_info = loader.get_template('VERSION.txt').render()
except TemplateDoesNotExist:
version_info = None
I considered loading the version info in default_settings but this isn't going to work since the template loader must be configured.
#2 Updated by Luke Murphey about 6 years ago
- [Done] JS (base.html)
- [Done] CSS (base.html)
- [Done] Riot tags (riot_tags.html)
- [Done] main.js (reference to app.js)
- [Done] app.js (reference to templates)
#3 Updated by Anonymous about 6 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Applied in changeset textcritical_git|r859.
#4 Updated by Luke Murphey about 6 years ago
- Status changed from Closed to In Progress
- % Done changed from 100 to 90
The only problem is that the cache busting prevents any caching of the templates and require JS loaded libraries.
#5 Updated by Luke Murphey about 6 years ago
I considered processing the main.js file to include the version information but this has some difficulties in that a temporary directory for the JS is not created since the files are processed from the src directory.
I could rename main.js though to something like main_2.0.js and then load the JS path via a variable. Thing is, the main.js doesn't need to be
Options¶
Use date-time in JS¶
Pros:- No build script updates required
- JS files are never cached by the client
Put JS files under a directory with the version info¶
Pros:- Caching is done by version
- Build script changes required that are non-trivial
Put JS files under a directory with the version info¶
Pros:- Browser caching is done by version
- Build script changes required that are non-trivial
Use JS version loaded from a chunk of JS code which specifies the version¶
Pros:- Simple build scripting
- Wouldn't work on async code easily
Have script introspect its own path for the version info¶
Pros:- Simple build scripting
- Unintuitive and questionably reliable (see https://stackoverflow.com/questions/710957/how-might-i-get-the-script-filename-from-within-that-script)
Use global app version variable¶
Pros:- Simple build scripting
- Requires setting a global variable
#6 Updated by Luke Murphey about 6 years ago
- Status changed from In Progress to Closed