| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | |
| 8 | 8 | if (!class_exists('berqWarmup')) { |
| 9 | 9 | class berqWarmup |
| 10 | 10 | { |
| 11 | + public $cache_warmup_fired = false; | |
| 12 | + | |
| 11 | 13 | function __construct() |
| 12 | 14 | { |
| 13 | 15 | |
| 14 | 16 | // Automatic cache warmup |
| @@ -41,8 +43,21 @@ | ||
| 41 | 43 | { |
| 42 | 44 | if (!berqwp_can_use_cloud()) { |
| 43 | 45 | return; |
| 44 | 46 | } |
| 47 | + | |
| 48 | + if ($this->cache_warmup_fired) { | |
| 49 | + return; | |
| 50 | + } | |
| 51 | + | |
| 52 | + // Debounce across separate requests (e.g. several plugin updates in a row) | |
| 53 | + if (get_transient('berqwp_warmup_running')) { | |
| 54 | + return; | |
| 55 | + } | |
| 56 | + | |
| 57 | + set_transient('berqwp_warmup_running', true, 5 * MINUTE_IN_SECONDS); | |
| 58 | + | |
| 59 | + $this->cache_warmup_fired = true; | |
| 45 | 60 | |
| 46 | 61 | global $berq_log; |
| 47 | 62 | $berq_log->info("Warming cache using sitemap."); |
| 48 | 63 | |