Super Cache garbage collection emails never arrive
-
I’ve been using Super Cache for over a year, but I’ve never received an email when the garbage collection runs–even though this feature is enabled.
Here are my setting:
Cache Timeout – 86400 Seconds
Scheduler – Timer – 86400 SecondsAny idea why the email never gets sent or if there’s another way I can check to see if garbage collection is running?
-
This topic was modified 5 years, 8 months ago by
chrislawhorn.
-
This topic was modified 5 years, 8 months ago by
-
Do you get emails regarding comments on your site?
You should enable the debug log in the plugin and see what happens there when garbage collection is supposed to happen. Set the timeout and scheduler to a small number so you’re not waiting for a long time.
Comments are disabled on the site, so there wouldn’t be any emails in my case.
I’ve enabled the debug log, but I’m not sure where I’d look in that to see if garbage collection is running.
That said, I set the timeout and scheduler to 60 seconds each and the number of expired pages–as listed in the Contents tab of the plugin–just continued to grow for the next hour.
This makes me think the garbage collection is not running.
Is that a correct assumption?
Unfortunately it probably isn’t working properly. 🙁
Look in the debug log linked from Settings->WP Super Cache->Debug for something like this:
/wp-cron.php?doing_wp_cron=1603045723.2620060443878173828125 gc: deleted ABSPATH/wp-content/cache/supercache/[YOUR URL]/2020/10/08/blog-title, older than 60 secondsThanks for following up.
I changed the timeout and scheduling settings to 60 seconds and ran the debug for an hour.
There were no references to “gc” anywhere in the resulting php doc.
Instead, I get a lot of entries that look like this:
16:35:31 29745 /URL/ wpsc_get_auth_cookies: no auth cookies detected 16:35:31 29745 /URL/ wpsc_is_caching_user_disabled: false 16:35:31 29745 /URL/ wp_cache_get_cookies_values: return: 16:35:31 29745 /URL/ supercache dir: /home/SERVER/sites/URL/current/public/wp-content/cache/supercache/www.URL.com/URL/ 16:35:31 29745 /URL/ wp_cache_get_cookies_values: return: 16:35:31 29745 /URL/ Cache has expired and is older than 60 seconds old. 16:35:31 29745 /URL/ wp_cache_get_cookies_values: return: 16:35:31 29745 /URL/ wp_cache_phase2: No caching to do as user agent rejected.So, it’s searching files, discovering that they are expired, but not taking them out.
Not sure if this matters, but I have the wp-cron.php running every 30 minutes via cron job.
Having run for 60 minutes, it should have run twice.
But, does the cron need to run more often to make garbage collection work?
general WordPress cron job disabled and run it manually.
-
This reply was modified 5 years, 7 months ago by
chrislawhorn.
This line is odd – “No caching to do as user agent rejected”. Do you have any entries in the user agent field on the advanced settings page?
Here are the user agent entries:
bot
ia_archive
slurp
crawl
spider
YandexI thought these were default entries. Is that not the case?
Those are the defaults. I wonder if some other plugin on your site is messing with the user agent field?
Around line 1542 of wp-cache-phase2.php add this line:
wp_cache_debug( "wp_cache_user_agent_is_rejected: rejecting user agent " . $headers['User-Agent'] );So that chunk of code should look like this:
foreach ( $cache_rejected_user_agent as $user_agent ) { if ( ! empty( $user_agent ) && stristr( $headers['User-Agent'], $user_agent ) ) { wp_cache_debug( "wp_cache_user_agent_is_rejected: rejecting user agent " . $headers['User-Agent'] ); return true; } }Then check your debug log again next time you load the page. It should tell you what user agent was rejected.
-
This reply was modified 5 years, 7 months ago by
Donncha O Caoimh (a11n).
Thanks for following up.
I’ve added the code you suggested, and here’s a sample of the new output from the debug file:
17:42:26 13943 XXXURLXXX wpsc_is_caching_user_disabled: false 17:42:26 13943 XXXURLXXX wp_cache_get_cookies_values: return: 17:42:26 13943 XXXURLXXX supercache dir: /home/XXXURLXXX 17:42:26 13943 XXXURLXXX No Super Cache file found for current URL: /home/XXXURLXXX 17:42:26 13943 XXXURLXXX wp_cache_get_cookies_values: return: 17:42:26 13943 XXXURLXXX wp_cache_user_agent_is_rejected: rejecting user agent Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots) 17:42:26 13943 XXXURLXXX wp_cache_phase2: No caching to do as user agent rejected.If you have additional suggestions on how to resolve this issue–based on the output above–I’d be interested.
Thanks!
I’ve uploaded the information you requested–in a post over a month ago.
If you can follow up, I’d appreciate it.
Thanks!
The only thing I can think of is you debug the plugin manually. Use error_log() to send messages to a file on your server so you know different parts of the plugin are working. Unfortunately you’ll have to figure out which way of using error_log() suits your needs, the docs for it are here: https://www.php.net/manual/en/function.error-log.php
I usually feed my error logs to a file in /tmp/ like this:
error_log( “test message”, 3, “/tmp/error_log.txt” );To debug the garbage collection, add error logging to wp-cache-phase2.php above:
Line 1393: “Set up garbage collection cron”
Line 3126: “wp_cache_gc_cron: 1 doing gc”
Line 3132: “wp_cache_gc_cron: 2 doing gc”And so on through the wp_cache_gc_cron function and see if those appear in the log file. If you don’t see anything there I am out of ideas.
If you do see those but you still don’t get emails then check if you can get emails from your server.
Edit wp-admin/index.php and after the line that loads admin.php add this, replacing “myemail” with your email.
if ( isset( $_GET['s'] ) ) { wp_mail( 'myemail', 'I got mail', 'mail works!' ); die( "sent email!" ); }Then go to https://<yoursite>/wp-admin/?s=1 and you should see the message “sent email”. Check your inbox.
If garbage collection is still not working, look in the function “wp_cache_phase2_clean_expired” and error log that.
-
This reply was modified 5 years, 7 months ago by
The topic ‘Super Cache garbage collection emails never arrive’ is closed to new replies.