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.

At the moment I run PHP code in my side bars. Even though I have the following

header("Pragma: no-cache");
header("cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

It still appears to serve cached content.

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

This can be accomplished with fragment caching feature that W3TC has. Had been asked/answered couple times.

share|improve this answer
add comment

Those headers which you've put in your question apply to the entire page, you can't set them just for a sidebar as the page has already been loaded at this point.

You could do as Ross said and alternatively load the sidebar fragment after the page has loaded via ajax, or you could use an iframe to load in. You could then use the headers to set the expiry of the sidebar content separately to the main page.

share|improve this answer
add comment

You'll probably need to find a solution that loads this content via JavaScript...unfortunately. That's the only way around this issue that I've found. I've solved it by building a container and a separate (non-cached) PHP file that gets whatever content you'd want in the sidebar.

Then...use jQuery's ".load" to pull the PHP content into that container on the cached page. Works well for me here: http://www.missouladowntown.com.

Hope that helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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