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'm running the latest version of both Wordpress (3.5.1) and the always popular W3 Total Cache (0.9.2.8), but I'm having issues with the browser cache. Basically I can't figure out the settings to make it so that my homepage isn't being cached.

Whenever I turn on the browser cache, it effectively caches my homepage and stops showing any new posts that I make. My inclination is to lower the HTML & XML Expires header lifetime down to something like 900 seconds (15 minutes), but I'm not 100% sure that would solve my problem here.

Thanks in advance for any help on this!

share|improve this question

put on hold as off-topic by mrwweb, Johannes Pille, Pieter Goosen, birgire, G. M. 17 hours ago

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." – mrwweb, Johannes Pille, Pieter Goosen, birgire, G. M.
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
How often are you pushing new content? Remember, the majority of most sites' traffic is the front page, so if you don't cache that you're losing the benefit of caching in the first place. Lowering the cache duration to something small should alleviate the problem. It means people will wait no longer than X minutes to see new posts on the home page. –  EAMann Feb 20 '13 at 19:49

1 Answer 1

There are two steps necessary to make sure that the browsers fetch the updated HTML pages (ex: home page).

Step 1

Uncheck 'Set expires header' at your site's wp-admin/admin.php?page=w3tc_browsercache#html_xml, for 'HTML & XML' files.

Whenever a browser sees an Expires header, it (the browser) will fetch the next version of that particular HTML page only after it expires. The Expires header specifies a date after which a resource (home page / HTML page) is invalid.

Step 2

In your site's 'Browser Cache' at wp-admin/admin.php?page=w3tc_browsercache#html_xml, for 'HTML & XML' files, the 'Cache Control Policy' should probably be 'cache with max-age and validation ("max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate").

Like the 'expires' header, the max-age header specifies how long a resource (home page / HTML page) is valid after it is downloaded.

When using this cache control policy, W3 Total Cache would additionally send two headers...

  1. Last-Modified header
  2. ETag header

The use of ETag is redundant (IMO), when Last-Modified header is present. So, it is safe to remove ETag header after it is generated by W3 Total Cache.

When the home page is not updated and when browsers tries to fetch the same page that is already in the browser cache, the W3 Total Cache sends 304 Not Modified status code. If the home page is updated and if the browsers tries to fetch the same page that is already in the browser cache, W3 Total Cache sends the updated home page with the updated Last-Modified and ETag headers.

For more details on Expires and max-age headers, please check out... https://developers.google.com/speed/articles/caching

If you use Firefox, you may use Live HTTP Headers add-on to check how all the above headers work in real time.

share|improve this answer

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