Plugin Directory


Ignore:
Timestamp:
10/01/2026 12:31:38 PM (4 weeks ago)
Author:
shiponkarmakar
Message:

Release v1.0.24

File:
1 edited

Legend:

Unmodified
Added
Removed
  • optimazz/trunk/includes/Modules/Cache/Manager.php

    r3617648 r3723128  
    7878                }
    7979
     80                // Keep the auto-preload schedule in step with the settings right away
     81                // (interval changes, preloading or caching switched off).
     82                Preloader::schedule(
     83                        ! empty( $cache_settings['enabled'] ) && ! empty( $cache_settings['preload'] ),
     84                        isset( $cache_settings['preload_interval'] ) ? (string) $cache_settings['preload_interval'] : 'twicedaily'
     85                );
     86                if ( empty( $cache_settings['enabled'] ) ) {
     87                        wp_clear_scheduled_hook( Preloader::HOOK . '_once' );
     88                        Preloader::sync_due();
     89                }
     90
    8091                // Browser cache headers (.htaccess) — on when caching + browser_cache are.
    8192                $browser = ! empty( $cache_settings['enabled'] ) && ! empty( $cache_settings['browser_cache'] );
    8293                BrowserCache::apply( $browser );
     94        }
     95
     96        /**
     97         * Purge every cached page and, when page caching and preloading are on,
     98         * queue a rebuild right away.
     99         *
     100         * Use this whenever a SETTINGS change forces a full purge (switching a
     101         * module on/off, changing an option, Undo, Reset, the post-update
     102         * reconciliation, the safety guard). A bare purge leaves the cache empty
     103         * until each page happens to get a visitor or the twice-daily preload runs,
     104         * so the site looks uncached — and slow — after every change.
     105         *
     106         * @return void
     107         */
     108        public static function purge_and_rewarm() {
     109                self::storage()->purge_all();
     110
     111                $cache = ( new \Optimazz\Core\Settings() )->for_module( 'cache' );
     112                if ( ! empty( $cache['enabled'] ) && ! empty( $cache['preload'] ) ) {
     113                        Preloader::queue_soon();
     114                }
    83115        }
    84116
Note: See TracChangeset for help on using the changeset viewer.