Best practice for caching with members enabled

Hi everyone,

Are there any best practices published for caching content in Ghost v3 with members enabled?
Is there anything that shall be kept in mind when setting up a site?

Interesting question @ceecko! What are your specific concerns around this? :slight_smile:

My understanding of members feature is that content served by Ghost changes based on whether a user is a member or not. Typically a member gets access to an article while non-member gets to see only a preview.

Since members content is rendered server-side, I was wondering if it is possible to make use of a cache in front of Ghost (such as Varnish). Two identical requests may be rendered differently over time since a membership may have already expired between the first and second request.

I understand Ghost in production is not meant to scale horizontally, ie. running multiple Ghost processes since it’s not designed in such a way.

What are some recommendations to run Ghost in production with members feature enabled in case a site gets tons of traffic and a single process cannot handle it anymore?

The TLDR is respect cookies :slight_smile:

Varnish does this out of the box, so you should be fine.

1 Like

Without members the cookies do not seem to be relevant for frontend (correct me if I’m wrong).
However with members cookies seem to play a role.

How does one scale a big Ghost site with members if you cannot cache content for members? Once the amount of traffic exceeds single Ghost process capacity, the site gets slow.
What are the recommendations here?

Is this a real world problem you’ve actually encountered in production?

1 Like

I’m considering Ghost as a replacement for a system which would enable membership subscriptions. It’s a high traffic site and during performance tests it popped up as an issue. It was a synthetic test, not in production but I don’t feel confident at the moment to make the switch.

For this reason I wanted to reach out and see if there’s anything that could be done.

I’m not entirely clear here what it is you are testing or testing for.

Caching with Varnish requires configuration and tweaking to get it right and depends on the shape of your traffic as to what you want to focus on, and how tricky it gets.

If you’re talking about a high traffic site with some members traffic, then caching all content that doesn’t have cookies should help dramatically. If you’re talking about a high-traffic site with members-only traffic, then you’re going to need to configure Varnish to cache against the cookies.

But the bottom line here is that members is a beta feature - it’s brand new, there will be teething problems, and performance under load is not something that a lot of time has been spent on yet.

1 Like

Based on my understanding of how Ghost works, I think it would be great if multiple processes could run concurrently without causing any issues.

If at least the frontend can run concurrently, that would help a lot. Backend requests can be directed towards a single process on load balancer level which shall solve the concurrency issue - if there’s any.

I think it would be great if multiple processes could run concurrently without causing any issues.

So do I, but there’s a huge amount of work required to get there.

1 Like