Page 1 of 1

Exclude the homepage from caching

PostPosted: May 19th, 2011, 6:40 pm
by Darsch
Hello!

Is there a way to exclude from the cache just the homepage? I've got a widget that randomize some stuff, and it would be great if I can avoid caching.
It seems that in the "No-Cache URI Patterns" field there's no way to put the site homepage.

Thanks, regards.

Re: Exclude the homepage from caching

PostPosted: May 20th, 2011, 3:26 pm
by julian1828
So this isn't a recommended fix, but it works.

  • Navigate to /wp-content/plugins/quick-cache/includes/templates/handler.tpl.php
  • Insert this at line 80:
    Code: Select all
    else if ($_SERVER["REQUEST_URI"] == "/")
        {
            return; /* Return now. Nothing more to do here. */
        } 
  • Save that.
  • Delete /wp-content/advanced-cache.php (for good measure)
  • Go to the settings for the Quick Cache.
  • Don't make any changes, just re-save the settings. This will recreate the advanced-cache.php file with your new changes.

Suggestion to developers:
I wish there was some filtering abilities on the cache. Such as, in the advanced-cache.php if statement, there should be an else if statement that runs a filter and returned result of the filter decides whether or not to continue. Here is an example of what I am talking about:
Code: Select all
else if (apply_filters ("ws_plugin__qcache_handler_validate", false))
    {
        return;
    } 
(same area as what I said above this section)

So then I would be able to attach a filter to the if statement in the advanced-cache.php. This would be useful for using my own criteria to decide what should be cached. Now I know this is probably a whole solution, as per the cron, etc., but it definitely be an improvement.

Re: Exclude the homepage from caching

PostPosted: May 20th, 2011, 4:00 pm
by Darsch
Wow, thank you very much!
Why it isn't a recommended fix? This doesn't seems to have any sort of strange side-effect or similar, does it?

Re: Exclude the homepage from caching

PostPosted: May 20th, 2011, 4:08 pm
by julian1828
the reason I say it isn't a recommend fix is because I am modifying the plugin. Once they update it, and if you accidentally upgrade it, your changes will be overridden. But no, there aren't any strange side-effects.

Re: Exclude the homepage from caching

PostPosted: May 20th, 2011, 4:13 pm
by Darsch
Oh ok, well in case of update I'll re-apply the fix (if they'll not add the feature officially). :)
Thanks again.

Re: Exclude the homepage from caching

PostPosted: November 8th, 2011, 3:12 pm
by ayman07
this didnt work and caused me to get the white page of death. luckily I managed to fix it. is there another method to doing this?

under the no cache uri you can put links for things that should not be cached. if i just put '/' will that work?

Re: Exclude the homepage from caching

PostPosted: January 6th, 2012, 7:03 pm
by doctorproctor
Okay, the above fix in handler.tpl.php works for me...ignore this posting for now!

Jim