How is Cache-Control: max-age affected by intermediate caching

cachecdnhttphttp-headers

I am currently serving an HTML page to users with a Cache-Control: max-age=600 header. I believe this allows the users' browsers to cache the page for a maximum of 10 minutes.

I am considering adding a CDN in front of my server which, due to the above header, should also cache the page for a maximum of 10 minutes.

If a user obtains the page when it has been in the CDN cache for 9 minutes, say, will it still be cached in the browser for 10 minutes, giving a total cached time of 19 minutes? Or will it only be cached in the browser for 1 minute?

Best Answer

Read this excellent article on cache control headers.

One idea is instead of specifying a ten minute caching time you can generate the page to include a precise date/time it expires. After that date/time any client will re-validate the resource. If you specify ten minutes you could potentially end up with 10 minutes on the CDN and 10 minutes on the client. So the solution could be to change it to 5 minutes, but this will increase server load and response time.

However I think Michael's answer of "it could be anything" is probably the best answer you'll get to your precise question. You will need to do some testing with your particular CDN.