Title: Cache cleaning problem
Last modified: August 20, 2016

---

# Cache cleaning problem

 *  Resolved [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/)
 * Hello,
 * I think I have found a problem with WP Super Cache cleaning expired files.
 * I use the mod_rewrite cache. So, when all pages are cached, of course there is
   not anymore calls to PHP files which could clean something.
 * So I have deactivated the wp-cron.php call in WordPress to make it manually by
   crontab.
 * While I have the cron calls which are working great now with the crontab, the
   WP Super Cache still not clean the expired files.
 * The crontab is called every 5 min, and the delay of expired files is 1 min.
 * I have looked at the plugin code trying to understand how this plugin works. 
   We can see that in wp-cache-phase2.php file, there is the function wp_cache_phase2()
   wich manage if the current viewed page should be cached or not, and only after
   that, activating the garbage colelctor.
 * The problem with this, if I’m right, is that calling wp-cron.php will never do
   something, because this page is never cached, and since the functions which are
   activating and scheduling the GC (wp_schedule_single_event) are called only if
   we are currently on a page which could be cached (if not it’s just return false
   and doesn’t move forward), it will never work.
 * Please tell me if I missed something or what.
 * Thanks

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117841)
 * You should probably mark one page as uncacheable in the settings page and call
   that every few minutes. That will call the cron system.
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117845)
 * I don’t think it will solve the problem.
 * wp-cron.php is already an uncacheable page, due to this restriction in default
   settings:
    wp-.*\.php
 * And I call the wp-cron page every 5 minutes by crontab.
 * But in your code, when a page is marked as uncacheable, the phase 2 is stopped
   before the garbage system is called, so the GC is never called after this :
 *     ```
       if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
                       if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'URI rejected. Not Caching', 2 );
                       return false;
               }
       ```
   
 * So if I’m not wrong, I think there is no way to refresh the cache actually with
   the mod_rewrite cache configuration.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117847)
 * I just remembered a simple way around this. Add ?blah=1 or any GET parameter 
   to the url and it won’t be cached by the plugin. wp-cron.php will be called then.
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117852)
 * If I call the index WP page with ?bla=1 , it’s doing a new cache, but not a good
   one.
    It’s generating a simple wp-cache html cache file, and not a super cache
   file, due to this part of code in phase2 I guess:
 *     ```
       if ( !empty( $_GET ) ) {
                       if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non emp
       ty GET request.', 5 );
                       $super_cache_enabled = false;
               }
       ```
   
 * but it should still call the garbage collector I think… but for now it doesn’t,
   I try to check why.
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117864)
 * Ok I got the problem why the cache is still not cleared.
 * The garbage collector is called correctly when I add ?bla=1 . But in the code
   posted above, there is:
 * `$super_cache_enabled = false;`
 * Then the problem is in the garbage collector, in the function prune_super_cache(),
   there is this test:
 *     ```
       if( !is_admin() && $super_cache_enabled == 0 )
                       return false;
       ```
   
 * since $super_cache_enabled is global, it is false, and the super cache is not
   cleaned because the function stop here.
 * So we still have a problem here I think 😉
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117902)
 * I don’t think that matters. All you’re trying to do is forcing your blog to execute
   PHP so it’ll spawn wp-cron.php. That in turn executes the garbage collection.
 * The process that runs the garbage collection is not the ?blah=1 request. 🙂
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117903)
 * Ok I will continue my tests today and keep you posted here, I have to make it
   work 🙂
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117940)
 * After adding a lot of debug everywhere in phase2, I found the problem !
 * It was the problem noticed above, the super_cache_enabled was going to false,
   due to GET not empty.
 * But why even in cron call ?
 * Because in the crontab, I was calling “wp-cron.php?doing_wp_cron” , like it was
   in many tutorials “how to add wp cron in crontab”.
 * Due to this wp super cache was detecting the GET “doing_wp_cron” and deactivated
   super cache. So the super cache garbage collector was not called.
 * I just removed “doing_wp_cron” in crontab, and now it works perfectly !
 * thanks
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117941)
 * Ah, glad you got it sorted!
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117942)
 * But now I’m not sure about one thing, does the normal WP cron call by WordPress
   is also adding “doing_wp_cron” ?
 * I see this in my server logs:
 * xxx.xxx.xxx.xxx – – [08/Jun/2011:09:00:01 +0200] “POST /wp-cron.php?doing_wp_cron
   HTTP/1.0” 200 173 “-” “WordPress/3.1.3; [http://xxx.com&#8221](http://xxx.com&#8221);
 * So there may be still a problem with the classic internal wp cron call, since
   it’s also adding a GET here.
    May be the test “if ( !empty($_GET) )” in phase2
   should care of it.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117968)
 * That “doing_wp_cron” string is appended to the file normally but I don’t think
   it matters because it’s the WP cron scheduler that calls the clear cache routine.
 *  Thread Starter [the_spy](https://wordpress.org/support/users/the_spy/)
 * (@the_spy)
 * [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117969)
 * Finally I have put back the “classic” wp cron system instead of calling it by
   crontab, and now I just call the index page with ?bla=1 by crontab to schedule
   and start wp cron.
 * I call this page every 5 minutes, so the old cache is cleared every 10 minutes(
   first 5min to schedule the cron, next 5min to launch scheduled crons).
 * Thanks

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Cache cleaning problem’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [the_spy](https://wordpress.org/support/users/the_spy/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/cache-cleaning-problem/#post-2117969)
 * Status: resolved