MDL-64835 JS: Stop using the jsrev in the jsrevPrefix
commit8bb8d213db7077791e571adb1dcf594e5446ddfb
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 12 Feb 2019 23:37:03 +0000 (13 07:37 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 13 Feb 2019 02:13:56 +0000 (13 10:13 +0800)
tree7b3391102b8d86e412fbf78c9e542f436c1ca924
parentbe521ca625501b86560377cf2691c6b8830b420f
MDL-64835 JS: Stop using the jsrev in the jsrevPrefix

We only use the jsrevPrefix to determine if the cache should be
invalidated, but the prefix that we were using is based on the new
jsrev.

For example, the jsrevPrefix will be:

    hash(wwwroot + '/ + config.jsrev) + '/jsrev'

Where config.jsrev is the _current_ (new) jsrev.

As a result when searching for the jsrev used to store the data which is
currently in the storage cache, no key is returned, and we instead set
an 'initial' value and the cache is not cleared

This patch changes the jsrevPrefix to be:

    hash(wwwroot) + '/jsrev'

Since the wwwroot does not change, the key remains static for the
current site. As a result, when the jsrev is bumped via a Moodle cache
purge, we are able to correctly fetch the old jsrev from the cache,
determine that the jsrev has changed, and purge the cache.
lib/amd/build/storagewrapper.min.js
lib/amd/src/storagewrapper.js