Caching and Wordpress Add this story to Scoopit!.

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.

No TweetBacks yet. (Be the first to Tweet this post)
Tags:

6 Responses to “Caching and Wordpress”

  1. Peter (217) Says:

    Look up WP Super Cache. Probably need to run it as a cron job on the server.

  2. David Farrar (1310) Says:

    The problem is this is hosted by wordpress.com, not hosted on a server I control.

  3. scrubone (171) Says:

    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?

  4. Rex Widerstrom (2513) Says:

    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…

  5. Rex Widerstrom (2513) Says:

    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 :-/

  6. labrator (625) Says:

    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(); ?>

Leave a Reply

You must be logged in to post a comment.