HTTP Cache Example

Source: Internet
Author: User

when the server receives the request,   200OK   last-modified   ETag header , the client saves the resource in the Cache and records both of these properties. When the client needs to send the same request, will carry if-modified-since and If-none-match in the request . two x head . Two header values are in response last-modified and the ETag the value of the header. The server uses these two headers to determine that the local resource has not changed, the client does not need to re-download, return 304 Response. The common process is as follows:




The image above is the time to visit Baidu, the black request is to obtain resources, the gray request is to send the validity confirmation, and then next from the cache server to obtain resources.
The following is the header for HTTP requests using cache resources, which can be seenThe response from the cache server and the response header to the resource server for validation.


Request header for the first request:


because the HTTP response sets the date and expires fields to the same value, the cache server does not cache the resource, so it will request the source resource server every time. Max-age set to 0 also allows validation of the source server to be validated every time, rather than a time period.


Verify with the source server that there is a if-modified-since field in the header that tells the server to accept only resources that have been modified since that time, and returns 304 if there is no modification after that time.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HTTP Cache Example

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.