Add? V = version number after JS or CSS to prevent browser from caching

Time:2019-12-2

Copy code

The code is as follows:

< span style = “font size: 14px;” > CSS and JS with parameters (such as. CSS? V = and. JS? V = or. CSS? Version = and. JS? Version =)
<script type=”text/javascript” src=”jb51.js?version=1.2.6″></script>
<link rel=’stylesheet’ href=’base.css?version=2.3.3′ type=’text/css’ />

There are two possibilities for using parameters:

First, the script does not exist, but is generated dynamically by the server, so it has a version number to show the difference. That is, the above code is equivalent to

Copy code

The code is as follows:

<script type=”text/javascript” src=”jb51.js”></script>
<link rel=’stylesheet’ href=’base.css’ type=’text/css’ />

But the browser will think that he is a version of the file!

Second, the client will cache these CSS or JS files, so every time the JS or CSS file is upgraded, the client browser will download the new JS or CSS file again after changing the version number, which is the function of brush cache. You may sometimes find that when you modify the style or JS, the refresh time is the same, that is, the client cache the CSS or JS file, so adding parameters is still good!
The second situation is the most, or both. </span>