How does html5 promptly update cached files (js, css, or images)

Source: Internet
Author: User

Comments: When we use offline cache, resources, such as js, css, or image updates, may be updated. A problem arises: how can users update cache resources in a timely manner? The following describes the specific solutions in detail. For more information about similar cases, refer to. When using offline cache, resources, such as js, may be updated, css or image updates. However, the old version of the resource has been cached by the user before the update. During the next access, the user still uses the old version of the resource. How can the user promptly update the cache resource?

There are two main methods to update cache resources: modifying the version number of the configuration file or calling js to complete the update
Js update Method

The Code is as follows:
If (window. applicationCache. status = window. applicationCache. UPDATEREADY ){
Window. applicationCache. update ();}

Modify file
Update the manifest File
When the browser finds that the manifest file has changed, it obtains new resources for caching based on the new manifest file.
When the manifest file list does not change, we usually change the file by modifying the manifest comment to update the file.
Note change refers to the version number of the configuration file.

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.