Search code examples
phpapache.htaccesscache-control

PHP Cache Headers with CDN


I am trying the php header() function to set caching headers to my page. I have a CDN that caches the http requests. What I am trying to achieve here is that the CDN should cache my page for 2 days, and the browser should check for new version to the CDN every 5 minutes.

Cache-Control: max-age=300, s-maxage=172800, public

Does this avoe cache header work?


Solution

  • Does this avoe cache header work?

    Why don't you know from your traffic?

    Manual:

    s-maxage
       If a response includes an s-maxage directive, then for a shared
       cache (but not for a private cache), the maximum age specified by
       this directive overrides the maximum age specified by either the
       max-age directive or the Expires header.
    

    Yes, it should work - but makes no sense to use a shorter expiry time on the client than on an intermediate proxy (unless the client is likely to move between different CDN zones and the content is CDN zone specific).