Fastly 后方登录状态不一致

我遇到一个有点奇怪的问题,但涉及的因素很多。

问题:

当我已登录并直接导航到论坛首页时,UI 显示我似乎未登录,例如导航栏显示的是注册/登录链接,而不是用户头像。

直接导航到特定帖子时,会显示正确的已登录状态,随后的 pushstate 转换也能正常工作,包括前往首页。但是,在首页刷新后,又会显示为未登录状态(如上所述)。

背景:

我的 Discourse 完全部署在 Fastly 后面,除了轮询功能外,其他都通过 Fastly 处理;轮询功能直接与我的 GCP Compute 实例通信。

我猜测这与缓存层有关,但我已经非常仔细地阅读了本论坛上的相关讨论。我没有启用 Fastly 的自动 GZIP 压缩功能。

论坛地址在此上述问题的视频在此

2 个赞

Upon further investigation, I think the issue may be related to when the Cache-Control response header is no-cache, no-store in combination with Fastly not respecting those values.

My Fastly CDN was marking what looked like a noscript version of the home page for a web crawler as HIT’s because it must have crawled with the no-cache, no-store value.

Fastly suggests adding an Expires: 0 in situations like this.

I’ve implemented this as suggested by the fastly docs in the meantime.

1 个赞