Do not cache html element




Wordpress LScache Plugin: Do not cache html element

Last Updated on: Wed, 15 Apr 2026 00:00:02
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 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] you can also try use ESI block please check this page https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url You can also consider to use JS to control that css class.



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference