Is s-maxage used by proxies or just reverse proxies?


As per this post:

I’m interested in using CloudFlare to improve page load times, and want to be able to cache html responses in CloudFlare for a long time (e.g. a year) but not allow browsers to cache the page. That way if I change a page I can purge the CloudFlare cache and it’s instantly available to users. Essentially I want to use CloudFlare as an on-the-fly static publishing system.

I was able to achieve this with a header like Cache-Control: s-maxage=86400, max-age=0 but I’ve been reading the spec a bit, and now I’m concerned that the s-maxage property will be picked up by unintended recipients such as ISPs or company proxy caches. If those proxies respect the s-maxage property, then they could continue to hold on to and serve an outdated html response, even after I purge the CloudFlare cache.

I really want to make sure that only CloudFlare will cache my html responses, and no one else (so that I have the ability to instantly purge the cache). Does anyone know how to do this?


On your page rule for caching everything, make sure to include an Edge Cache TTL setting with the desired time to cache the files. This will be the time Cloudflare will keep the cache on its servers. However, given the nature of CF CDN, it will only keep files at datacenters that were previously requested those files. Also, it may discard any cache that is not regularly requested, so do not trust the Edge TTL to keep for a long period of time a page that is infrequently visited.

At the Dashboard > Caching tab, you can set the Browser Cache Expiration to either a TTL you want or to Respect Existing Headers. At a Page Rule, you can only set the Browser Cache TTL to a set amount of time, minimum 30 minutes on the Free Plan.

If you set an specific time for Browser Cache, Cache Cloudflare will still respect existing headers for any amount of time that is greater than the generic Browser Cache Expiration you set.


To answer the question in the title:

Is s-maxage used by proxies or just reverse proxies?



Takes precedence over max-age or the Expires header, but it only applies to shared caches (e.g., proxies) and is ignored by a private cache.


Thank you for taking the time to help me out @floripare and @Judge. Given the limitations and my specific requirements it looks like I’m not quite going to be able to use CloudFlare to cache html in the way I hoped, so I’ll look at other strategies for that part of the equation.

1 Like

Thanks, I had read that article, I guess I was hoping irrationally that someone would say “only CloudFlare reads s-maxage” :smile: