Is it possible to not clear static pages (te ones specified in Authcache) after poormanscron run?
For sites with only loggedin users and a lot of static pages, the present situation is a wast of time and a loss of performance. Maybe there is already a solution?

Comments

Jonah Ellison’s picture

Status: Active » Closed (works as designed)

Page clear on cron is Drupal core behavior (poormanscron goes through Drupal core). The only way around this is to hack core, or hack cacherouter. You'll need to modify the cache_clear_all() function to detect if cron is running, then return instead of clearing.

janwalhof’s picture

Thank you for your comment. Can you tell me the best way (at cache_clear_all()) to check if cron is running?

Jonah Ellison’s picture

Sure thing...

At the top of poormanscron_run_cron_check(), add:

global $poormanscron;
$poormanscron = TRUE;

At the top of cache_clear_all() in cacherouter.inc, add:

global $poormanscron;
if($poormanscron && $table == 'cache_page') {
  return;
}
janwalhof’s picture

Jonah,

This is the solution were I was looking for. It works!
Thank you very, very much.

With regards,
Jan Walhof

janwalhof’s picture

It's a pitty, but it's not working.
When I run cronjob from the admin menu, then it is ok. The cache is not cleared.
But when the system runs cronjob after the timelimit and when a user enters the system, then the cache is cleared.
What to do?

Regards,
Jan Walhof

Jonah Ellison’s picture

Ah, I forgot about the general clear in cache_clear_all(). Try:

global $poormanscron;
if($poormanscron && ($table == 'cache_page' || (!isset($key) && !isset($table)))) {
  return;
}
janwalhof’s picture

Jonah,

After a few days following the changes, I'am sure now, this is a correct working patch!
I'm very happy with it. Thanks again.

Regards,
Jan Walhof

janwalhof’s picture

Jonah,

Working with your solution, a new question rises.
Is it possible to exclude the blocks left- and right in a way that the blocks change, as they do normal, if they have new content?

f.i. ??
if($poormanscron && ($table == 'cache_page' || (!isset($key) && !isset($table)))) {
global $cache;
if (!isset($cache)) {
$cache = new CacheRouter();
}
$cache->flush('cache_block');

}

return;

Jonah Ellison’s picture

You can flush the blocks, but the new block content won't show up unless you clear cache_page, since the cache_page bin holds the final HTML of a page, including block output.

janwalhof’s picture

Status: Closed (works as designed) » Closed (fixed)

Yes, I see. The present solution is fine.
Thank you again.
Regards