JavaScript file does not reload in browser when changing on server

So, I have this ASP.Net 2.0 site that uses the functions contained in the JS file. When the web page loads the js file, it loads normally. But when I change something in this file on the server, the changes do not apply to the user's browser. It continues to work according to an obsolete file. How to make the browser reload the modified file from the server?

+3
source share
2 answers

One fairly common solution (which is also used here in SO, I think) is to add a query string to the url of the javascript file containing the version number. When you change the query string, the browser will process it as a new file and load, and not select from the cache.

<script type="text/javascript" src="http://example.com/file.js?v=2"></script> 

In the above example, changing file.js?v=2to file.js?v=3will force the browser to download the file, rather than loading the cached ones file.js?v=2.

+8
source

In general, the fastest way to force an update is to press CTRL + F5 in a browser.

Otherwise, you need to clear your browser cache.

Firefox, -, " โ†’ โ†’ Cache".

+6

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


All Articles