Forced text RequireJS! reboot

Using text! plugin, is there a way to get RequireJS to reload the file rather than returning cached data?

+6
source share
2 answers

RequireJS will only cache the file per request. Reload the page will cause it to restart. If you see something else, this is because:

  • Or you have caching on your server.
  • or your browser caches the request. You can, of course, disable this in your browser.

If you want browsers to select a clean file each time, you should have a no-cache header for these resources on your server.

+1
source

I think you could add a new html5 cache function by providing a cache manifest: http://www.html5rocks.com/en/tutorials/appcache/beginner/

then you can use requirejs "domReady" to get the right load event: http://requirejs.org/docs/api.html#pageload

and then listen for the correct event (code taken from the first link):

window.applicationCache.addEventListener('updateready', function(e) { if (window.applicationCache.status == window.applicationCache.UPDATEREADY) { // Browser downloaded a new app cache. if (confirm('A new version of this site is available. Load it?')) { window.location.reload(); } } else { // Manifest didn't changed. Nothing new to server. }}, false); 

at this moment, when you update urlArgs, you will get new js files and with the manifest cache file you will get new html files

0
source

Source: https://habr.com/ru/post/908568/


All Articles