Home > Web Front-end > JS Tutorial > 2 solutions to browser cache problems such as js, css, img and so on_javascript skills

2 solutions to browser cache problems such as js, css, img and so on_javascript skills

WBOY
Release: 2016-05-16 17:19:09
Original
1386 people have browsed it

Details determine success or failure! The significance of browser caching is to improve execution efficiency, but it also brings some problems, causing the server to modify js and css, and the client cannot update
Method 1 generates random numbers

Copy code The code is as follows:



Disadvantage, browser cache is meaningless and is loaded dynamically every time.

Method 2 version number control, set global variables, increase the version number by 1 before each release
Copy code The code is as follows:



Recommended this method, this method is relatively simple. The disadvantage is that HTML pages cannot be used, but there should not be too many such pages

More methods: Automatically implement it by reading the file size and file modification time to generate MD5, compressing and merging js when the program is automatically built, and global The replacement version is complicated. If you are interested, you can study it

Who has a better method?
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