Support » Plugin: WP Super Cache » A more than excellent plugin ! + Question

  • boddhid

    (@boddhid)


    Caching is complex and WPSuperCache (Version 1.7.1 on WP 5.3.2) does a more than excellent job! The plugin is small and powerful at the same time. We use it for 4 websites in combination with the Themeco Pro Theme and Autoptimize.

    Thanks a lot!

    One question: we are now doing part of the preload based on sitemaps (see below). We could imagine that preloading based on sitemaps would make sense in general. Could it become an option in WPSuperCache?

    Our experience: it took us some time however to set up preload. Below the settings that work for us. What made it difficult is that the messages in dashboard sometimes don’t tell the full truth and looking at the code was the only way out. E.g. the message reads ‘In ’Preload Mode’ regular garbage collection will be disabled so that old cache files are not deleted.’ but in wp_cache.php on line 3670:

    if ( $wp_cache_preload_interval > 0 ) {
    $cache_max_time = (int)$wp_cache_preload_interval * 60; // fool the GC into expiring really old files
    } else { … }

    The more precise message would be something like ‘Posts (and if set, also terms and categories) are preloaded, all other pages will be deleted after one day.’
    It is funny that one day is considered ‘really old’ 🙂

    We added a function to also preload pages from custom apps:

    function preload_sitemaps() {

    $log_msg = ‘Started sitemap curling at ‘.date(‘Y-m-d H:i:s’).’, ‘;

    $sitemapFiles = array(
    1 => “https://…-sitemap.xml”,
    2 => “https:/…-sitemap.xml”,
    );

    foreach ($sitemapFiles as $sitemapId => $sitemapFile) {

    $sitemapHtml = wp_remote_get( $sitemapFile, array(‘timeout’ => 60, ‘blocking’ => true ) );
    $sitemapXml = new SimpleXMLElement( wp_remote_retrieve_body($sitemapHtml));
    foreach ($sitemapXml->url as $url_list) {
    $url = $url_list->loc;
    wp_remote_get( $url, array(‘timeout’ => 60, ‘blocking’ => true ) );
    sleep( 1 );
    }

    }

    $log_msg .= ‘finished sitemap curling at ‘.date(‘Y-m-d H:i:s’).’.’;

    return $log_msg;
    }

    For setting-up preload we used the following settings:

    1) Switch on preload
    Preload mode (garbage collection disabled. Recommended.) = set
    Refresh preloaded cache files = 1440 minutes

    2) Cache Delivery Method = Expert
    Remark: we’ve put the first set of mod_rewrite rules into the .htaccess file inside the WordPress directory, since we have more than one WordPress install on the same shared server. The second set of mod_rewrite rules we’ve put where WPSuperCache told us to.

    Be aware to also leave the ‘BEGIN WPSuperCache’ and ‘END WPSuperCache’ tags, since these are used for checking whether the rules are in .htacces.

    3) Cache Timeout = 0 seconds
    Notification Emails = set
    Remark: A timeout larger than 0 seconds, caused the garbage collector to run and clean-up the cache. This took us some time to find out, since the comments read ‘Warning! PRELOAD MODE activated. Supercache files will not be deleted regardless of age.’ and also the status email reads ‘WP Super Cache Garbage Collector has now run, deleting 0 files and directories.’. After setting Cache Timeout to 0 seconds the notification emails were not sent anymore, probably part of the garbage collector code stills runs even if preload is active.

    • This topic was modified 4 years ago by boddhid.
    • This topic was modified 4 years ago by boddhid. Reason: Added some more info on how preload functions. Removed the feature requests
    • This topic was modified 4 years ago by boddhid. Reason: Updated the preload function for custom sitemaps
    • This topic was modified 4 years ago by boddhid. Reason: Added question
  • The topic ‘A more than excellent plugin ! + Question’ is closed to new replies.