Exclude content from w3 total cache [closed]

I use w3 total cache on a site I run which also now has to display a small popup at the bottom of the page to mention that the site uses cookies (thanks EU). The idea is that this only appears the first time the user sees the page, a cookie is then set to make sure the site doesn’t show this user the popup again.

However W3 will often cache a version of the site with this popup visible meaning the popup is shown regardless of the cookie existing or not.

The popup is drawn with a <div> at the bottom of each page and it is only drawn if the cookie is set. Essentially the question is, how can I exclude W3 cache from always showing this? Is this even possible, or is there an alternative to how this popup is shown that gets around this issue?

Thanks.

1 Answer
1

In W3TC you can specify files or cookies that are ignored and not cached.

Exclude Files from Cache
To do this go to WordPress Admin > Performance > Page Cache

In the screenshot … you will see I’ve added custom sidebars from a Twenty-Eleven theme. These are excluded from being cached.

W3TC excluded files

You can also specify your custom cookie to not be cached …

Browser Cache Settings
BUT also check your Browser Cache settings as you’ll probably want to reduce these from 1 year to 1 month or week or day.

Leave a Comment