Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why the web Front end uses caching

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "why the web front end uses cache", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "why the web front end uses caching" this article.

First, why use caching?

1. Speed up requests: caching content in a local browser or on the nearest server greatly increases the loading speed of the site without affecting interaction.

two。 Save broadband: cached files can reduce requests for broadband.

3. Reduce server pressure: when a large number of users request concurrently, it can balance the load and reduce the pressure.

Second, how to set the cache?

1.HTML Meta tag control cache (non-HTTP protocol definition)

We use the following code to set it up and tell the browser that the current page is not cached, so every visit will go to the server to get it. The code is as follows:

2.HTTP header information control cache

This method is implemented through Expires (strong cache), Cache-control (strong cache), Last-Modified/If-Modified-Since (negotiation cache) and Etag/If-None-Match (negotiation cache).

(1)。 Expires (strong cache) describes an absolute time that is returned by the server.

(2)。 Cache-control (strong cache) is also a way to describe relative time, which is safer and more effective in comparison with Expires (strong cache). And the values in this method can be public, private, no-cache, no- store, no-transform, must-revalidate, proxy-revalidate, max-age and so on. If we use both methods at the same time, the browser will only execute one. Because Cache-Control takes precedence over Expires in response header.

(3) .Last-Modified/If-Modified-Since (negotiation cache) this method needs to be used with Cache-Control.

(4). Etag/If-None-Match (negotiation cache) this method is also used with Cache-Control.

The above is all the content of the article "Why the web front end uses caching". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report