Cache Static Home Page

We would like to cache the home page HTML for our websites by using a Page Rule.
We anticipate setting the page to cache for 1 hour.

But our home page varies slightly when a user logs into the site. When they do that a few changes occur in the heading. Log In is removed, View Account and Log Out is added.

This has to be a very common feature of most websites. What is the best practice for handling this situation?

Business Plans are able to bypass cache if there’s a login cookie. For lower plans, you’re stuck unless you get into using Cloudflare Workers for the bypass:

1 Like

Great. We are an Enterprise user, we protect multiple hosts through our Cloudflare instance and the platform that we are using is our own. Therefore we can easily plant a cookie when the user is logged in. Let’s say our cookie is “LoggedIn”. Then is this the Page Rule that you would suggest that we setup:

If the URL matches: *.com/
Then the settings are:
Bypass Cache on Cookie LoggedIn
Edge Cache TTL an hour
Cache Level Cache Everything

Our goal initially is to cache the home page HTML (and everything else for the home page) if we are responding to a website visitor that is not yet logged in.

*.com is probably too general :slight_smile:

** should be sufficient. Though, this will basically disable the cache for logged in users sitewide. Is this what you intend to do?

As Enterprise user, though, I’d recommend to discuss this with your solution engineer. He should know your site best and should be able to provide the most applicable recommendation/suggestion for your requirements/case.

This topic was automatically closed after 30 days. New replies are no longer allowed.