Fastly 背後でのログイン状態の一貫性のない問題

少し奇妙な問題が発生しているのですが、関与している要因が多数あります。

問題:

ログインした状態でフォーラムのトップページに直接移動すると、UI 上ではログインしていないように表示されてしまいます。例えば、ナビゲーションバーにユーザーアバターではなく、サインアップ/サインインのリンクが表示されます。

特定の投稿に直接移動すると、正しいログイン状態が表示され、その後のプッシュステート遷移(ホームページへの移動を含む)も正常に動作します。ただし、ホームページをリロードすると、上記のようにログアウト状態のように表示されてしまいます。

背景:

Polling 機能(GCP Compute Instance と直接通信する部分)を除き、Discourse はすべて Fastly の背後で運用しています。

この問題はキャッシュ層に関連しているのではないかと思われますが、このフォーラムでの議論を慎重に確認してきました。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