Inconsistent Signed-In State behind fastly

I’m having a bit of a strange issue but there are a lot of factors at play.

Issue:

when I am logged in and I navigate directly to my forum’s home page, it appears as if I’m not logged in, in the UI e.g. the navbar has sign-up/sign-in links instead of the user avatar.

Navigating directly to a specific post, will result in the correct signed-in state and subsequent pushstate transitions work, including going to the home page. However, a reload on the homepage will result in it appearing logged out (as above).

Background:

I am using discourse fully behind Fastly, except for the polling functionality which is communicating directly with my GCP Compute Instance.

My guess is that this has something to do with the caching layer, but I have been pretty careful to read through the discussions on this forum. I do not have Fastly’s automatic GZIP compression turned on.

The forum is here and here’s a video of the above.

2 Likes

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 Like