• Resolved kees78

    (@kees78)


    Hi,

    I have written a php function that adds a class to an html element if a cookie exists.
    However, this html is cached if a page has been visited before.
    How can i exclude this html element (it is a header > navigation element, so it is on every page active).

    Kind regards, Kees

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

    (@serpentdriver)

    1 way to exclude output from beeing cached is to use this cookie for cache vary. For example:

    RewriteCond %{HTTP_COOKIE} cookiename [NC]
    RewriteRule .* - [E=Cache-Control:no-cache]

    If this rule should only be active on a specific URL:

    RewriteCond %{HTTP_COOKIE} cookiename [NC]
    RewriteCond %{REQUEST_URI} ^\/url
    RewriteRule .* - [E=Cache-Control:no-cache]
    Plugin Support qtwrk

    (@qtwrk)

    you can also try use ESI block

    please check this page

    https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url

    Plugin Support Hai Zheng⚡

    (@hailite)

    You can also consider to use JS to control that css class.

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

The topic ‘Do not cache html element’ is closed to new replies.