In CloudFlare, present cached page only if cookie is not set

南笙酒味 提交于 2019-12-07 12:03:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!