Home >Web Front-end >HTML Tutorial >What are the different mechanisms between js caching and static html caching? _html/css_WEB-ITnose

What are the different mechanisms between js caching and static html caching? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:13:56914browse

For html, it will be compared with the server-side file according to the last modified, and then decide whether to use local cache, so if the html changes, the client will update immediately. But if js is modified, sometimes the client will not be updated. Isn't js judged based on last modified?
After updating, you must add a change parameter (such as v=11) after the js path to update the client.


Reply to discussion (solution)

It’s different.

The document itself is retrieved from the Cache directory based on Last-Modified.
There are some things that Last-Modified cannot solve. For example, some files will be modified periodically, but the content may not change every time.
Etag in HTTP1.1 can solve this problem.

For Css files, Javascript files, images, etc., a unique parameter is used, such as the v=11 you mentioned.

If you want to know more, you can take a look at the HTTP protocol for Last-Modified and the definition of ETag

I saw someone in our company writing code just add a change parameter at the end. It is said to prevent caching. I don’t know how to ask for an expert

I saw someone in our company writing code just add a change parameter at the end. One change parameter is said to be to prevent caching. I don’t know if I’m asking for an expert
. It’s equivalent to my V=11. Some pictures still need to be cached. In this case, without caching, the performance will be poor.

Statement:
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