I'm trying to prevent CloudFlare from hitting our servers if a user is not logged in, but instead to get the cached object if possible. We're setting a cookie ('email') if the user is logged in, and clearing it when the user is logged out.
Is this possible?
In order to do this you can use a feature called "Bypass Cache on Cookie". This allows you to specify a Regex string of what type of cookie you want to Bypass:
When used in conjunction with a Cache Everything Page Rule, you can use this setting to cache anonymous page views but bypass the cache when a cookie exists.
Further reading:
It is possible in Business plan only using page rules.
More info here.
来源:https://stackoverflow.com/questions/34686709/in-cloudflare-present-cached-page-only-if-cookie-is-not-set