Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Jonah Ellison CreditAttribution: Jonah Ellison commentedPage 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.
Comment #2
janwalhof CreditAttribution: janwalhof commentedThank you for your comment. Can you tell me the best way (at cache_clear_all()) to check if cron is running?
Comment #3
Jonah Ellison CreditAttribution: Jonah Ellison commentedSure thing...
At the top of
poormanscron_run_cron_check()
, add:At the top of
cache_clear_all()
in cacherouter.inc, add:Comment #4
janwalhof CreditAttribution: janwalhof commentedJonah,
This is the solution were I was looking for. It works!
Thank you very, very much.
With regards,
Jan Walhof
Comment #5
janwalhof CreditAttribution: janwalhof commentedIt'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
Comment #6
Jonah Ellison CreditAttribution: Jonah Ellison commentedAh, I forgot about the general clear in cache_clear_all(). Try:
Comment #7
janwalhof CreditAttribution: janwalhof commentedJonah,
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
Comment #8
janwalhof CreditAttribution: janwalhof commentedJonah,
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;
Comment #9
Jonah Ellison CreditAttribution: Jonah Ellison commentedYou 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.
Comment #10
janwalhof CreditAttribution: janwalhof commentedYes, I see. The present solution is fine.
Thank you again.
Regards