• Resolved Cees Rijken

    (@connectcase)


    Hi there, I need some help with a custom cookie in a WordPress site (PHP’s setcookie command). I am using this cookie to show some content (if the cookie is set, then don’t show XYZ etc.).

    Everything works as intended when the Litespeed plugin is deactivated. When LS plugin is activated, the cookie is set correctly, but Chrome completely ignores it. Firefox ignores it twice, but acknowledges it the third time (?) etc. So unpredictable behavior all around.

    So I am basically looking for a way to honor the changes in a cookie, while still caching the PHP page that set this cookie. Is that possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • This hasn’t something to do with any browser. If a cookie is set and content changes if this cookie is set a different copy of the cache with same URL must be created. For this LScache uses cache vary. Documentation knows a lot about this:

    https://docs.litespeedtech.com/lscache/devguide/advanced/#cache-varies

    This should do what you need. Set your cookie name for my_cookie.

    RewriteRule .? - [E=Cache-Vary:my_cookie]

    You can also disable caching if your cookie is set. See plugin settings.

    • This reply was modified 2 years, 6 months ago by serpentdriver.
    Thread Starter Cees Rijken

    (@connectcase)

    Thanks! I searched for the documentation but could not find, so much obliged for the direct link.

    Disabling caching when cookie is set is no option, because it will slow down the page too much….

    Try the code from my last post.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Honoring a cookie while still caching’ is closed to new replies.