简体   繁体   中英

What should my expires, cache-control, and pragma HTTP request header fields be set to?

I have a website in which I update the content approximately once monthly. When I check the HTTP request header fields, I get the following output:

Expires: Thu, 19 Nov 1981 08:52:00 GMT  
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0   
Pragma: no-cache

My question is, given the frequency at which I update content, I am thinking about manually setting these fields to allow cache of the site. I am using the php header(); command to do so.

Therefore, my question is: what should my expires, cache-control, and pragma HTTP request header fields be set to? Also, should I be setting any other fields in addition to those?

您可以考虑使用ETAG - http://en.wikipedia.org/wiki/HTTP_ETag

Your Expires header should be the date in the future at which time the content will expire and caches will be forced to fetch it again.

Get rid of the Pragma header

For Cache-Control you can add: public max-age=2592000

Assuming you want it cached for 30 seconds.

For greater control you should follow hafichuk's advice and use ETags.

For references on cache headers check out Headers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM