The method is as follows:
1. Manually clear the browser cache;
2. Add the version number (such as layout.css?v=1)
Personally, I think method 2 is faster, because clearing the browser cache requires waiting for the browser to respond. But it is troublesome to change the version number every time, so we need to find a way to automatically add the version number.
(Recommended tutorial: html tutorial)
Method 1: You can automatically add the version number to html through js
<script type="text/javascript"> document.write("<link rel='stylesheet' type='text/css' href='/css/layout.css?v="+new Date().getTime()+"'>"); </script>
Method 2: If it is a jsp page , you can use java code to generate timestamps (if it is a jsp page, you can also use method 1, but this method is more convenient)
<link rel="stylesheet" type="text/css" href="/css/layout.css?v=<%=System.currentTimeMillis() %>">
For more programming-related content, please pay attention to the php Chinese websiteIntroduction to Programming Column!
The above is the detailed content of HTML implements automatic cleaning of the cache of js and css files. For more information, please follow other related articles on the PHP Chinese website!