During the development of the web project, we often quote CSS and JS files. After updating files, cache problems often occur (clearly changed the code, but it has not changed when accessing on the browser). In this case, we usually use the following two two Solution:
1. Manually clear the browser cache
2. Add version number (such as layout.css? V = 1)
Personally think that method 2 is faster, because the browser cache has to wait for the browser to respond. However, the version number is also troublesome each time, so you need to find a way to automatically add the version number.
The following is the method of collecting myself:
Method 1: You can automatically add version number to HTML via JS<script type = Text/Javascript> Document.write (<link Roth = 'Stylesheet' Type = 'Text/CSS' HREF = '/CSS/Layout.css? V =+New Date (). Getttttttttttt Ime ()+'> ); </script>Method 2: If the JSP page, you can use the Java code to generate a timestamp (if the JSP page is used, but this method is more convenient)
<link rel = styleSheet type = text/css href =/css/layout.css? v = < %= system.currenTtimememillis () %>>Method 3: Use other methods to add version number, such as node.js automatic configuration, etc.
PS: The purpose of removing the cache is to see the update of the page in time. When we go online (that is, the deployment to the formal environment, we will not make a change again). Quick, change the fixed version number when you need to update.
The above is all the contents of this article. I hope it will be helpful to everyone's learning. I also hope that everyone will support VEVB Wulin.com.