javascript - How to clear the browser cache after the tomcat service is started?
怪我咯2017-05-17 10:07:22
0
7
731
After the Tomcat service is started, js and css cannot be refreshed in real time due to browser cache. Is there any way to clear the browser cache when the customer logs in to send a request?
If we just talk about browser cache, I suggest you use the incognito mode of Google Chrome. There will be no cache or cookies in incognito mode. The shortcut key to open it is . On Mac, replace ctrl with commd. ctrl +shift+n
1. Go to /work/Catalina/localhost corresponding to tomcat and find the corresponding project folder. Delete it, or delete the /localhost folder directly. This step is just to clear the jsp cache. 2. Static files such as js/css files Add the version number at the end, such as /common.js?v=1.0 3. You can add no-cache restriction in the head to cancel the page cache
If we just talk about browser cache, I suggest you use the incognito mode of Google Chrome. There will be no cache or cookies in incognito mode. The shortcut key to open it is
. On Mac, replace ctrl with commd.
ctrl +shift+n
1.ctrl+F5 refresh all resources.
2.js/css added version control
If you don’t want to clear the cache, add a timestamp after the request.
This is what it looked like before upgrading:
.../.../foo.js?v=1
,升级之后这样:.../.../foo.js?v=2
The browser cache has nothing to do with restarting Tomcat. Every browser has it. There are three ways to clear the cache. As follows:
Clear all browser caches, take chrome under mac as an example, chrome preferences-advanced settings-privacy settings-clear browsing data
Open the console and check ☑️ Disable cache
Ctrl+Shift+N or Command+Shift+N to open the privacy window
1. Go to /work/Catalina/localhost corresponding to tomcat and find the corresponding project folder. Delete it, or delete the /localhost folder directly. This step is just to clear the jsp cache.
2. Static files such as js/css files Add the version number at the end, such as /common.js?v=1.0
3. You can add no-cache restriction in the head to cancel the page cache
This needs to be cleaned by the user themselves! Unless you dynamically obtain static resources