Title: Preload cache and stop
Last modified: February 13, 2024

---

# Preload cache and stop

 *  Resolved [fkoomek](https://wordpress.org/support/users/fkoomek/)
 * (@fkoomek)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/preload-cache-and-stop/)
 * Hello.
   Is it possible to run the preload function from start to beginning according
   to the sitemap and then stop?I got a complaint from my host provider that the
   preload is too aggressive and that it runs continuously. Is there a function 
   that I could use?Thanks,Radan

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

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/preload-cache-and-stop/#post-17421646)
 * Hello [@fkoomek](https://wordpress.org/support/users/fkoomek/)
 * Thank you for reaching out and I am happy to help!
 * Yes, the cache preload runs until the website is preloaded and then starts from
   the beginning. You can try adding a smaller amount of pages and increasing the
   interval. 
   This will ensure less server consumption. Alternatively, you can disable
   wp_cron and use wp-cli:wp w3-total-cache pgcache_prime [–start=<start>] [–limit
   =<limit>]
 * The idea of the cache priming is that you always have fresh cache served for 
   the visitors. There is a chance that the cache is purged if triggered by altering
   the pages adding or changing some plugin settings, adding a new post, etc. and
   you want the cache preload to kick in in this case.
 * I am not sure which settings are used for cache priming in yoru case, however,
   the default 10 pages per 900s should not cause a lot of server resource consumption.
 * I hope this helps!
   Thanks!
 *  Thread Starter [fkoomek](https://wordpress.org/support/users/fkoomek/)
 * (@fkoomek)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/preload-cache-and-stop/#post-17422345)
 * Thank you for your help. 
   I understand but I would rather clear and preload the
   cache all at once in some given interval. So what I did now is that I disabled
   the priming of the cache automatically ind your plugin and instead I use this
   code:
 *     ```wp-block-code
       /*w3tc preload manually*/
       // Schedule the event
       add_action('init', 'schedule_pgcache_prime');
       function schedule_pgcache_prime() {
           // Get the current time in the Prague time zone
       date_default_timezone_set('Europe/Prague');
       $current_time = current_time('timestamp', true);
       // Get the current hour and minute separately
       $current_hour = date('G', $current_time);
       $current_minute = date('i', $current_time);
   
       if (($current_hour == 0 && $current_minute >= 10) || ($current_hour == 1) || ($current_hour == 2 && $current_minute < 10)) {
               // Schedule the event to run every minute
               if (!wp_next_scheduled('w3_pgcache_prime')) {
               wp_schedule_event(time(), 'every_minute', 'w3_pgcache_prime');
       		}
       	   }
       		else{
       	// Unschedule the 'w3_pgcache_prime' event
       wp_clear_scheduled_hook('w3_pgcache_prime');
       	}
       }
       ```
   
 * I am also calling w3tc_flush_all(); before the preload begins.
   So, now the cache
   is cleared at 0:10, and then preload starts from 0:10-2:10 which is enough to
   finish it and then it stops. It’s true that I am using pretty aggressive preload
   30pages/minute.
 * Radan
    -  This reply was modified 2 years, 3 months ago by [fkoomek](https://wordpress.org/support/users/fkoomek/).
    -  This reply was modified 2 years, 3 months ago by [fkoomek](https://wordpress.org/support/users/fkoomek/).

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

The topic ‘Preload cache and stop’ is closed to new replies.

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

 * 2 replies
 * 2 participants
 * Last reply from: [fkoomek](https://wordpress.org/support/users/fkoomek/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/preload-cache-and-stop/#post-17422345)
 * Status: resolved