问题
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?
回答1:
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:
- Caching Anonymous Page Views
- How do I cache static HTML?
- Technical Details: Bypass Cache Cookie (Business and Enterprise Only)
回答2:
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