Clear the cache of css, javascript, and background images in the browser, and cssjavascript

Source: Internet
Author: User

Clear the cache of css, javascript, and background images in the browser, and cssjavascript

In the actual project development process, the page is uploaded to the server. To reduce the load on the server and reduce the load on the server, the browser caches images, css, and js to the Local Machine for the next visit to the website. This not only reduces the pressure on the server, but also reduces the number of user downloads and provides a better user experience.

However, when you upgrade the version or make some css, js, and other adjustments, the cache will make the user unable to display the updated style, which is another headache. Unless you manually upgrade the cache, almost all users do not manually clear the cache for normal access to this website, because the user does not know whether it is a cache problem. In the final analysis, the user thinks that your page is faulty and cannot be accessed normally.

In order to properly use the cache and avoid such problems, we can think about it. What if we solve this problem?

If the style is changed, what is the name of the style file? The answer is yes. verification will not be performed here. However, it is too troublesome to manually change the file name every time. Can you change the file name without having? The answer is yes. We can add a version number after the introduced file name, which is different from the previous version number (generally the update date ). The Code is as follows:

<link rel="stylesheet" type="text/css" href="reset.css?v=20140829"><script type="text/javascript" src="core.js?v=20140829"></script>

We can see that my CSS file name and JS file name are followed by "v = 20140829". In this way, the file name can be updated in real time without being changed and cached. However, "v = 20140829" is generally used to writing and can be changed to others.

The last part is the image. Generally, images with the img tag will not be duplicated, because they are all file names generated in the background. For images with fixed file names, the method is the same as above. For the background image, the resolution path of the image is updated and synchronized because the style name is changed, so the background image is also updated.

 


Javascript gets the browser cache address and saves it in the browser cache through the javascript bar network.

Javascript cannot do this.
Browser cache is completely managed by the browser
Javascript can store images to the filesystem of html5, but only modern browsers can support
 
How to use javascript to clear the ssl cache of ie

I have studied this problem for a long time and have not completely solved it yet ~

Conclusion: JS may fail to do so ~

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.