Title: Do not cache html element
Last modified: May 24, 2022

---

# Do not cache html element

 *  Resolved [kees78](https://wordpress.org/support/users/kees78/)
 * (@kees78)
 * [4 years ago](https://wordpress.org/support/topic/do-not-cache-html-element/)
 * 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](https://wordpress.org/support/users/serpentdriver/)
 * (@serpentdriver)
 * [4 years ago](https://wordpress.org/support/topic/do-not-cache-html-element/#post-15673567)
 * 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](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [4 years ago](https://wordpress.org/support/topic/do-not-cache-html-element/#post-15674681)
 * you can also try use ESI block
 * please check this page
 * [https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url](https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url)
 *  Plugin Support [Hai Zheng⚡](https://wordpress.org/support/users/hailite/)
 * (@hailite)
 * [4 years ago](https://wordpress.org/support/topic/do-not-cache-html-element/#post-15675457)
 * 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.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)

 * 3 replies
 * 4 participants
 * Last reply from: [Hai Zheng⚡](https://wordpress.org/support/users/hailite/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/do-not-cache-html-element/#post-15675457)
 * Status: resolved