Caching and WordPress

Most people will have seen the sidebar graphic with the Curiablog poll average. I update it everytime there is a new poll by replacing the graphic file at curiablog with a new graphic.
By keeping the file name the same, it means other sites (such as Kiwiblog and Policy Net) can have the graphic automatically updated.
But there is a problem. WordPress seems to cache the old graphic and it takes one to two days for the new graphic to appear.
Anyone know of a way to stop this by clearing the cache? Note that curiablog is run on wordpress.org – it is not my own installation.


September 27th, 2008 at 10:08 am
Look up WP Super Cache. Probably need to run it as a cron job on the server.
September 27th, 2008 at 10:27 am
The problem is this is hosted by wordpress.com, not hosted on a server I control.
September 27th, 2008 at 10:36 am
You should correct the post – it reads wordpress.org
Have you tried putting the actual file on this site, and including a reference to it on that one?
September 27th, 2008 at 3:50 pm
Well there’s always <meta HTTP-EQUIV=”Pragma” CONTENT=”no-cache”> in the metatags part of the page header (assuming there’s nothing else you can do, because that’s not always respected by browsers, though I believe adding <meta http-equiv=”expires” content=”0″> as well captures the majority).
Now no doubt someone who knows WordPress (I haven’t a clue) is about to come along and make me look like a twat. Oh well…
September 27th, 2008 at 4:09 pm
Okay that makes even less sense unless I explain I’m suggesting that go into the tags on the pages of any blog displaying the graphic, not the one on which it’s hosted. And that it works client-side by telling the browser to reload a fresh copy of the page and its content every time it visits (which slightly degrades performance, I know).
Unless you use Flash *shudder*. I think I saw this done via DHTML once. If I could shake of this spring flu I might remember where :-/
September 28th, 2008 at 9:59 am
From what I can tell, it’s not a problem with the page, it’s a problem with the headers being set on the image on the way out. This is a server configuration issue and it’s unlikely you can change it, although WordPress pros may know better.
Each image you’re uploading has an expires header set 1 week in the future. This is a common feature on high bandwidth sites to conserve said bandwidth. To get around this you could either wrap the serving of the image in a custom PHP file and set your own expires headers, or you could get the consumers of your images to link to the file with a timestamped querystring. Typically if any file has a different querystring, browsers will treat it as a separate file and get it again, so if you keep changing the querystring, they’ll keep getting it.
Try like this:
imagename.gif?t=<? echo time(); ?>