Configuring page rules to be ignired if response header exists

page-rules

#1

I have modified my website to allow for all pages to be cached, even if the user is logged in. An ajax request is used to load the user data on every page load meaning i can comfortably cache the html for every single dynamic page and not have the risk of any wires getting crossed.

The issue I have now is that pages like /myprofile and /editpost/123 are being cached and i do not want this. I have a LOT of pages that require this. I also do not want to cache any of the responses for these ajax requests, but i might just route those through a subdomain that cloudflare isnt caching. Either way, I would like to be able to return a custom http header in the response for certain pages that I do not want cached.

So if a user visits /myprofile, cloudflare will first check to see if the response contains “do-not-cache”, or whatever and if it does not, run the page rule. This way i can have server side control over what gets cached and what does not. My site has about 15 sub sections, all of which have their own share of dynamic edit pages that are locked to specific users.

I do not want to use cookies as a way to control this. Cookies are set for non logged in users as well as logged in users. Since a user being logged in has no influence on whether i cache the HTML or not, I would rather not have cookies play any part in the decision on whether to cache a page. Id like to have a blanket rule to cache everything and an exception to not cache when a header is returned from the origin server telling cloudflare not to cache


#2

Set the Cache-Control header is set to “private”, “no-store”, “no-cache”, or “max-age=0”.