I was having a bit of difficulty with a WordPress developed site recently. I had set up a members area which allowed users to retrieve messages and downloads, but users were finding that they would get a cached version of the page and would need to do a force refresh (e.g. Shift+F5 or Ctrl+Shift+R depending on your browser of choice) to get the latest version. I did not have a caching plugin installed on the site so was at a loss as to how to solve this issue.

In the end, I found a forum post on the WordPress Support site which helped me solve the issue. All that I had to do was edit the header.php file of my custom template, and add the following four lines right at the top of the file (just underneath the <?php tag):

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');

Now users will be able to see the latest messages and downloads without having to do a force refresh themselves. This is obviously at a cost of extra bandwidth, but it’s worth it so that the site acts as it should and users see up-to-date information.

Leave a Reply

Your email address will not be published. Required fields are marked *