HTTP Cache Related Header

Source: Internet
Author: User

Cache-control:

No-cache#不使用本地缓存. You need to use cache negotiation to confirm with the server whether the returned response is changed or not, and if there is an etag in the previous response, the request will be validated with the service side, and if the resource has not been changed, you can avoid re-downloading

No-store#直接禁止游览器缓存数据, each time a user requests the resource, a request is sent to the server, and the full resource is downloaded each time

Public#可以被所有的用户缓存, including intermediate proxy servers such as end users and CDNs

Private#只能被终端用户的浏览器缓存, does not allow the CDN cache server to cache it

Max-age The maximum time (in seconds) to allow the retrieved response to be reused, starting from the current request


Cache policy based on file modification time

Last-modified#response

If-modified-since#request


When the browser requests the resource for the first time, the server Last-modified:thu the last modification time of the resource, and 18:23:55 GMT is returned to the browser on the response header, and the second request The browser will put the last time the server returned the modification times in the request header If-modified-since:thu, 2011 18:23:55 sent to the server, the server will take this time and the server's resources on the latest modification time to compare, If the two are equal or greater than the most recent modification time on the server, then the cache is valid, the cache is hit, the server no longer returns the content to the browser, and the last-modified header does not return, because the resources are not modified and return is meaningless. If the cache is not hit, the newly modified resource is returned together with the last-modified header.


Cache policy based on file content

ETag#response

If-none-match#request


The process of Etag/if-none-match and last-modified/if-modified-since is actually similar, the only difference being that it is based on summary information (such as MD5 hash) of the content of the resource. When the browser sends a second request, the value of the first response header information ETag is sent to the server in the If-none-match request header, compared to the latest resource summary information, if the browser cache is equal, the content is updated, the latest resources are returned with the latest summary information. The advantage of using the etag is that if, for some reason, the modification time of the resource does not change, then the etag can be used to differentiate whether the resource has been updated.




Expires

Expires is the header information that http/1.0 appears, the same is used to determine the local cache policy header, it is an absolute time, the time format is like Mon, June 21:31:12 GMT, as long as the sending request time is before the expires, then the local cache is always valid, Otherwise it will go to the server to send a request for a new resource. If both cache-control:max-age and expires are present, then the max-age priority is higher

Age#文件已经缓存的时间

Date#当前时间/Request Send time


This article is from the "LINUXGFC" blog, make sure to keep this source http://linuxgfc.blog.51cto.com/6117252/1876652

HTTP Cache Related Header

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.