简体   繁体   中英

cache-control:max-age=0 and If-Not-Modified in http request

Our site uses akamai as its CDN. Since there is browser cache, after cache expires in browser, it will send cache-control:max-age=0 and If-Not-Modified in the http request which will get a 304 response.(I think this 304 is retured from origin web server)

cache-control:max-age=0 will force CDN forward this http request to the origin web server, so why do we need a CDN?

I am not sure which type of http reuqest is served by CDN...and how CDC keep update with origin server?

By setting the max-age to 0, you effectively expire your page in your CDN edge cache immediately. Therefore, your CDN always hit your origin and render the CDN useless as you suggested.

You have to review the configuration and rules of your specific CDN to confirm its policies on refreshing its edge cache from your origin, but all I've ever used absolutely review the cache-control and the max-age ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 ). Most will also let you use instead of the Expires header instead if you prefer for whatever reason ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21 )

Since you are on Akamai, you can use the Edge-Control header to override your cache-control header.

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