Support » Plugin: WP Super Cache » [Plugin: WP Super Cache] Is it possible to set the cache to expire at set intervals?

  • Hi guys,

    I wonder if anyone can help. WP Super Cache is proving to be a bit of a life saver and I’m seriously impressed with how easy it is to get up and running compared with other caching plugins I’ve tried. It just works. Full stop.

    However, the site I’m currently building has multiple adverts on each page that ideally need to be randomised (the adverts are custom post types in WordPress and served up using a custom WP loop). And, of course page caching doesn’t allow this. I was hoping there would be a way to automatically force the cache to refresh every x minutes so that we’d get the best of both worlds: caching to aid performance and ads that rotate every few minutes.

    I can’t seem to find a way to do this. if I change the “expiry time” setting under “Expiry time and garbage collection” it makes no difference – the cached file is still being served up until I manually clear the cache. Performance is amazing though! 😉

    Am I missing something, or is what I’m asking simply beyond the remit of the plugin? Is there something else I can do to enable this type of randomisation of adverts, while also allowing page caching to take place?

    Any help or advice will be seriously appreciated.


Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Donncha O Caoimh


    The plugin should clear it’s cache every X minutes by default. There’s an expiry time on the advanced settings page. If it’s not you should probably enable debugging in the plugin as that will probably tell you what’s going wrong/not happening.

    Thanks donncha. That’s exactly what I tried to do and it’s not working. I’ll try the debug tools as suggested

    Thanks Donncha,

    I’ve done a little more testing and it looks like there’s something in my php code that’s preventing the automated garbage collection from happening. I’m trying to track it down by the good old comment everything out and then uncomment things one at a time.

    Hopefully it won’t be anything too horrendous to fix, but I’ll post the results anyway.


    Hi Donncha,

    Ok, I have something for you:

    Including modernizr.js in the <head> of the web page appears to be preventing the garbage collection from operating. I’ve tested it a number of times and it consistently appears that that’s causing the major issues here. Even if the loading of another page on the website causes the garbage to be collected, the page with modernizr seems to take much, much longer to refresh.

    Any ideas why that might be causing the issue and if there’s anything I can do about it? (modernizr is extremely useful for helping me provide the correct javascript).

    Separate from the modernizr.js issue, if I set an expiry time of around 10 seconds, the cache is actually cleared (garbage collected?) around once every minute or two (so the adverts displayed on each page appear to rotate every couple of minutes).

    I know this is probably an unusual use of WP Super cache – will such a short expiry time cause any problems with the website performance or server load do you think? What if I increased the expiry time to 1 minute?

    And following on from that, is there any way to speed up the cache clearing / garbage collection to perhaps every thirty seconds (so the adverts appear to rotate every thirty seconds) without causing any problems?

    This is for a commercial project, so I don’t object to making a donation as a contribution towards your efforts if it’ll help out. Regardless, any help you can offer will be very seriously appreciated.


    Hi Donncha,


    I just came across some documentation on the plugin page that talks about including dynamic cached content using PHP. This sounds interesting. Perhaps this is how I should be trying to rotate the adverts instead of going for a very short expiry time. Hmmm… looks interesting – I’m going to investigate 🙂


    Ok, so I just don’t know when to give up sometimes:

    So the weird thing is that I moved the HTML code that embeds modernizr a little further up the document and guess what – garbage collection is working again. Now that’s what I call weird. No idea why that would have caused the issue, but at least I’ve solved it.

    On the matter of using dynamic cached content – this is looking pretty complex to implement with my advertising code, so I think I’m going to forget about that for now.

    I’d really appreciate if you’d be willing to comment on point 2. in my previous post above, concerning how often the garbage is cleared from the server. (no need answer any other part of this topic now I’ve resolved the modernizr issue).


    Alrighty. This has really been doing my head in. It really does have nothing to do with modernizr, but it does somehow relate to files linked to from HTML. When I was trying to get to the bottom of the issue earlier, I commented out my php code, like this:

    <script src="<?php //bloginfo('template_directory'); ?>/_js/modernizr.custom.08439.js"></script>

    So when it started working I thought modernizr as the problem. That’s not the case. The garbage collection actually suddenly started working because the browser was getting a “404 (not found)” error. I’ve replicated it by including HTML links to images or javascript files that don’t exist- it seems the 404 error is the only way to get WP Super Cache plugin to clear the garbage collection, certainly according to the stats reported in the “contents” tab of the plugin settings.

    Could you please advise on this?


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: WP Super Cache] Is it possible to set the cache to expire at set intervals?’ is closed to new replies.