• I’m developing a site on which there will be some restricted content, I’ve created a custom login form and after a successful login a custom cookie will be created, this cookie provides access to the restricted content.

    Our hosts aggressively cache all live sites, caching breaks my functionality and I’m being told by our hosts that the only way this will work is by excluding all pages that require the cookie from the cache, and that this is ‘by design’ on all wordpress sites.

    Is this true, is there really no way that I can restrict content and have it cached in WP?

    • This topic was modified 5 years, 1 month ago by energycell.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s not a WordPress requirement, it’s the nature of caching. Caches can’t take the time to check cookies, they return whatever is requested without further fuss. If you need something different, it has to be excluded. This applies to any site, not just WordPress.

    Thread Starter energycell

    (@stonks)

    Thanks for replying.

    But it is possible to cache restricted content; W3 Total Cache plugin offers the option of caching content for logged in users.

    Originally I had an issue as I was serving either the login form or the restricted content on the same URL, I understand that this would have a problem with caching.

    To try to avoid this issue I created a separate login page to which the user gets redirected if they do not have the relevant cookie set.

    Moderator bcworkz

    (@bcworkz)

    W3TC devs would need to confirm, but I believe the logged in caching option still serves the same content whether logged in or not. The option AFAIK simply disables or enables the same caching. There’s not a separate cache for logged in users with different content for the same request.

    To cache variable content, you’d need a separate caching scheme applied only for logged in users. I’m unsure if such a thing exists. Usually variable content is simply excluded from caching and is served dynamically.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Caching restricted content’ is closed to new replies.