Home  >  Article  >  Web Front-end  >  Detailed explanation of why you need to add parameters after imported css or js files_jquery

Detailed explanation of why you need to add parameters after imported css or js files_jquery

WBOY
WBOYOriginal
2016-05-16 17:34:56917browse

css and js with parameters (in the form of .css?v= and .js?v=)

Copy code Code As follows:




There are two possibilities for using parameters,

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

for files. Copy the code and the code is as follows:

< script type=”text/javascript” src=”jb51.js”>


But the browser will think it is a certain version of the file!

Second, the client will cache these css or js files, so every time after upgrading the js or css file and changing the version number, the client browser will re-download the new js or css file, flushing the cache. effect. You may sometimes find that if you modify the style or js, it will not change when refreshing, that is, the client caches the css or js file, so adding parameters is still beneficial!
The second situation is the most common, or both may exist at the same time.

The version number can be a random number, or an incremental value, a large version and a small version, or written according to the generation time of the script. For example, 20080727182553 is accurate to the second when the script is generated, and 2.3.3 is The way of big version and small version

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn