在CloudFlare中,仅在未设置Cookie的情况下显示缓存的页面 [英] In CloudFlare, present cached page only if cookie is not set

查看:192
本文介绍了在CloudFlare中,仅在未设置Cookie的情况下显示缓存的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户未登录,我试图阻止CloudFlare攻击我们的服务器,而是尽可能地获取缓存的对象。如果用户已登录,我们将设置一个cookie(电子邮件),并在用户注销时将其清除。

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.

这可能吗?

推荐答案

为此,您可以使用绕过Cookie缓存功能。这样,您就可以指定要跳过的Cookie类型的正则表达式字符串:

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:

与缓存所有页面规则结合使用时,可以使用此设置缓存匿名页面视图,但是当存在cookie时绕过缓存。

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.

进一步阅读:

  • Caching Anonymous Page Views
  • How do I cache static HTML?
  • Technical Details: Bypass Cache Cookie (Business and Enterprise Only)

这篇关于在CloudFlare中,仅在未设置Cookie的情况下显示缓存的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆