How to understand the Cache-Control of Http request headers and response headers

Source: Internet
Author: User
The Cache-Control of the Http request header and response header is wordpress, and the Cache-Control in the request header is no-cache, in the response header, I set max-age = 259200 in nginx, so the browser does not cache it...

Request Headersview sourceAccept:*/*Accept-Encoding:gzip, deflate, sdchAccept-Language:zh-CN,zh;q=0.8Cache-Control:no-cacheConnection:keep-aliveCookie:CNZZDATA1254790698=1245005062-1429681029-%7C1429681029Host:yuanzi.mePragma:no-cacheReferer:http://yuanzi.me/User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36Response Headersview sourceAccept-Ranges:bytesCache-Control:max-age=259200Connection:keep-aliveContent-Length:100922Content-Type:application/javascriptDate:Wed, 22 Apr 2015 06:13:34 GMTETag:"55371597-18a3a"Expires:Sat, 25 Apr 2015 06:13:34 GMTLast-Modified:Wed, 22 Apr 2015 03:29:27 GMTServer:nginx/1.6.2


Reply to discussion (solution)

The Cache-Control in the request header is no-cache, and the browser notifies the server that data is not cached locally.
Cache-Control: max-age = 259200 in the response header is to notify the browser: do not bother me within 259200 seconds, refresh from the buffer

The Cache-Control in the request header is no-cache, and the browser notifies the server that data is not cached locally.
Cache-Control: max-age = 259200 in the response header is to notify the browser: do not bother me within 259200 seconds, refresh from the buffer



Moderator Xu ~
Still wondering, since there is no cached data locally, how can we refresh from the buffer ??
I set expires 3d in nginx. Is there any cache in the browser ??

I thought I set expires 3d, and the cache-control in the request header should also be 259200 ..

If the response header contains Cache-Control = no-cache, the browser will not Cache the response.
However, your response header does not exist, so it should be cached.
However, even if there is a cache, it is not necessarily used by the browser. Because the browser has other settings
At the same time, not all cache-related headers will be accepted by the browser. the protocol is only recommended and not necessarily executed.

If the response header contains Cache-Control = no-cache, the browser will not Cache the response.
However, your response header does not exist, so it should be cached.
However, even if there is a cache, it is not necessarily used by the browser. Because the browser has other settings
At the same time, not all cache-related headers will be accepted by the browser. the protocol is only recommended and not necessarily executed.



Thank you, moderator Xu ~

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.