Home > Web Front-end > H5 Tutorial > How to update cache files (js, css or pictures) in html5 in time_html5 tutorial skills

How to update cache files (js, css or pictures) in html5 in time_html5 tutorial skills

WBOY
Release: 2016-05-16 15:49:22
Original
2371 people have browsed it

When we use offline cache, we may sometimes update resources, such as js, css or image updates. But before the update, the user has cached the old version of the resource. When he accesses it again, he is still using the old version of the resource. How can the user update the cached resource in a timely manner?

There are two main ways to update cache resources, by modifying the version number of the configuration file or calling js to complete the update
js update method

Copy code
The code is as follows:

if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
window .applicationCache.update(); }

Modify the file
Update the manifest file
The browser finds that the manifest file itself has changed, and it will update the manifest file according to the new manifest file To obtain new resources for caching.
When the manifest file list does not change, we usually change the file by modifying the manifest comment to achieve the update.
The comment change refers to the version number of the configuration file
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template