In the process of web project development, we often reference css and js files. After updating the files, cache problems often occur (the code has been changed, but it has not changed when accessed on the browser). In this case, we usually use the following two solutions: 1. Clear the browser cache manually 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. Here is how I collected it: Method 1: You can automatically add a 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 a timestamp (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() %>"> Method 3: Use other methods to add version numbers, such as automatic configuration with node.js ps: The purpose of clearing the cache is to see the update status of the page in time. When we put the page online (that is, deploy it to the formal environment and will not make any changes), it is recommended to fix the version number, because the cached page is faster to access. When it needs to be updated, replace the fixed version number. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Detailed basic operations on data tables in MySQL database
>>: Example of implementing hollow triangle arrow and X icon with after pseudo element
In Linux, there are two types of file connections...
1. Download centos7 Download address: https://mir...
This article shares the specific code of JavaScri...
Table of contents 1. Check whether the docker env...
Website compatibility debugging is really annoyin...
Recently, I encountered a problem of whether the d...
Execute the create table statement in the databas...
Table of contents background Solution 1: Back up ...
Preface: It’s the end of the year, isn’t it time ...
Table of contents 1. Node builds HTTP server 2. H...
Table of contents 1. Introduction 2. Main text 2....
Table of contents Preface Core - CancelToken Prac...
Find two test machines: [root@docker1 centos_zabb...
MySQL InnoDB monitoring (system layer, database l...
Table of contents 1. Related binlog configuration...