Why the introduction of CSS or JS file after adding parameters of detailed explanation _jquery

Source: Internet
Author: User

CSS and JS with parameters (such as. css?v= and. js?v=)

Copy Code code as follows:

<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 possible uses of parameters,

The first, the script does not exist, but the server side dynamically generated, so with a version number, to show the difference. That is, the code above is equivalent to a file

Copy Code code as follows:

<script type= "Text/javascript" src= "Jb51.js" ></script>
<link rel= ' stylesheet ' href= ' base.css ' type= ' text/css '

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

Second, the client will cache these CSS or JS files, so each time you upgrade the JS or CSS file, change the version number, the client browser will download the new JS or CSS files, brush the role of caching. We may sometimes find that the modified style or JS, refresh the same time, that is, the client cache css or JS files, so add parameters are still good!
The second is the most, and there may be two of them at the same time.

The version number, can be a random number, or it can be an incremented value, a large version of the version of the way, or according to the script generation time to write, such as 20080727182553 is accurate to generate the script of the second, and 2.3.3 is a large version of the small version of the way

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.