Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

put on hold as off-topic by Mark Kaplun, birgire, Johannes Pille, G. M., Pieter Goosen Aug 26 at 4:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, birgire, Johannes Pille, G. M., Pieter Goosen
If this question can be reworded to fit the rules in the help center, please edit the question.

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.

share|improve this answer
    
The problem with this is that every page potentially shows the popup and therefore uses the cookie. This would remove all pages from the cache making it pretty redundant. I'm going to have to rethink this mechanism, maybe draw the popup using javascript so that W3 won't see it when creating the cache... assuming that W3 doesn't create the cache after any DOM changes. Thanks for the help anyway –  artparks Aug 15 '12 at 13:31
    
Hi @artparks the code for your popup could be put in its own file like /includes/cookie_warning.php it would then be just this one file to exclude + the sidebar or header.php –  Damien Aug 15 '12 at 15:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.