HTTP Protocol Cache

Source: Internet
Author: User

The HTTP cache is divided into client cache and server side cache

1. Client-Side Caching

Client-side caching refers to the browser cache, the browser cache is the fastest cache, because it is obtained directly from the local (but may need to send a request), it has the advantage of reducing network traffic, speed up the request

2. Server caching

The server cache refers to a reverse proxy server or CDN cache, and his role is to alleviate the stress of the actual Web server.

The cache is controlled by the header.

1. Expires

If the repsonse with expires=date, it means that the response can be saved by the browser/cdn to date, can be directly provided to the requester before the date is reached, for the browser cache, you can not have to send a request for the anti- To the proxy server, you can not request the original server

2. Cache-control

Cache-control has a lot of values, the most common is max-age, if response with max-age, it means that from now until Max-age, this repsonse can be used as a cache

Cache-control of the Server
1. No-store, prompt the client should delete this cache
2. No-cache, indicates that the client should not use the cache before re-verifying it
3. Max-age, which represents the cache's freshness time, can be used without sending an HTTP request to validate the cache and use it directly if max-age=0. Requires that the document not be cached
4. s-maxage, function same as max-age, but only for shared cache (CDN, reverse proxy)

Client's Cache-control
1. Max-stale, you can use outdated cache
2. Max-stale=s, within S seconds, the cache can expire
3. Min-fresh=s, the cache cannot expire within s seconds
4. Max=age=s, the cached age must be less than s second
5. No-cache, the cache is not accepted unless the resource is re-authenticated
6. No-store, indicates that the reverse proxy server should not cache the response of this request
7. Only-if-cached, just want the cached data, otherwise return 504

If Cache-control max-age and Expires exist at the same time, then Max-age first

3. Last-modified/if-modified-since

If response has last-modified, the request can be taken to the request header after the cache of Expires and Cache-control expires, using the time last-modified Fied-since, go to the server to verify that the cache has changed, and if server replies 304, you can continue to use the local cache

4. Etag/if-none-match

If the response has an etag, the request can take the value of the ETag to the request header If-none-match after the cache of Expires and Cache-control expires, if the server returns 304, you can continue to use the local cache

5. ETag & Last-modified

If the response contains both the ETag and the last-modified, the request needs to send both if-modified-since and If-none-match, and the server needs both the checksum pass to return 304.

HTTP Protocol Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.