In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "caching mechanism and use in HTTP". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Types of caches in HTTP
Caching is to save a copy of the requested resources locally, so that the copy is returned directly when the next request is made, and there is no need to download resources from the server, thus reducing the transmission of resources and improving efficiency.
In addition to directly accessing and returning resources, caches in HTTP can be divided into two categories, one is shared cache, that is, different clients can obtain resources from the shared cache, and these resources can be accessed by multiple clients. There is also a private cache, which means that the cache can only be accessed privately by the user or the client, and other users do not have access to it.
Private cache is easy to understand. The cache in our commonly used browsers is basically private cache. These cache are unique to browsers and will not be shared with other browsers.
Shared cache is mainly used on some web proxies, such as web proxy server, because the web proxy server may provide resource services for many users, it is not necessary for each user to save one copy of the resources accessed by these users, only one copy needs to be saved in the web proxy server, which can reduce the invalid copy of resources.
Status of cached responses in HTTP
For HTTP caching, the GET request is generally cached because the GET request has no extra parameters other than URI, and its meaning is to get resources from the server.
Different GET requests will return different status codes.
If the resource is returned successfully, 200 is returned to indicate OK.
If it is a redirect, 301 is returned. If it is an exception, 404 is returned. If it is an incomplete result, 206 is returned.
Cache Control in HTTP
Cache control in HTTP is represented by HTTP headers. With the addition of Cache-Control to HTTP1.1, we can control the caching of requests and responses through Cache-Control.
If caching is not required, use:
Cache-Control: no-store
If you need to validate the client's cache, use:
Cache-Control: no-cache
If you want to force validation, you can use:
Cache-Control: must-revalidate
In this case, expired resources will not be allowed to be used.
For the server, you can use Cache-Control to control whether the cache is private or public:
Cache-Control: privateCache-Control: public
Another very important cache control is expiration time:
Cache-Control: that's all for max-age=31536000 's "caching mechanisms and usage in HTTP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.