Project

General

Profile

Feature #2299

Ability to invalidate browser caches with version updates

Added by Luke Murphey about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
10/23/2018
Due date:
% Done:

90%

Associated revisions

Revision 858 (diff)
Added by lukemurphey about 6 years ago

Adding versioning of the CSS and JS files

Reference #2299

Revision 859 (diff)
Added by lukemurphey about 6 years ago

Adding cache busting for the JS and templates

Closes #2299

Revision 860 (diff)
Added by lukemurphey about 6 years ago

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

Things that cached by version:
  • [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
Cons:
  • JS files are never cached by the client

Put JS files under a directory with the version info

Pros:
  • Caching is done by version
Cons:
  • 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
Cons:
  • 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
Cons:
  • Wouldn't work on async code easily

Have script introspect its own path for the version info

Pros:
  • Simple build scripting
Cons:

Use global app version variable

Pros:
  • Simple build scripting
Cons:
  • Requires setting a global variable

#6 Updated by Luke Murphey about 6 years ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF