I am developing a webapp and the browser doesn’t consistently empty the cache each time I refresh, so sometimes I’m not getting the latest version of my JavaScript file loaded.
I would like to have a console message indicating if I’m using the latest version of the JavaScript file each time I refresh. I’m thinking that displaying the “last modified” time of the JavaScript file will do the job!
Any thoughts? Is there a standard solution to my problem that I’ve missed?
For production environments, whenever you modify your script file, you can alter your script tags to include a version querystring, so that the browser sees there is a new version and gets a fresh copy from the server:
This is just a simple trick that gives the browser a url it hasn’t seen before, forcing it to request the new file. The server ignores the querystring and just returns the script file.
For development environments, press ctrl+f5 to force the browser to fetch a fresh copy from the server.