Plugin Directory

Changeset 3788909


Ignore:
Timestamp:
11/07/2026 01:06:58 AM (less than one hour ago)
Author:
John Dagelmore
Message:

1.7.10 fastcache

Location:
fastcache-by-host-it/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fastcache-by-host-it/trunk/README.txt

    r3783868 r3788909  
    55Tested up to: 7.0
    66Requires PHP: 8.0
    7 Stable Tag: 1.7.9
     7Stable Tag: 1.7.10
    88License: GPL-2.0+
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    … …  
    152152
    153153== Changelog ==
     1541.7.10
     155Corretto Bug#34751: il warm-up dopo la pubblicazione ora salta i tipi di contenuto senza pagina pubblica (classi globali Elementor v4, template), richiede ogni indirizzo una sola volta per richiesta, con un massimo di 10 indirizzi e 25 secondi, e viene eseguito a fine richiesta senza far attendere il salvataggio. Lo stesso controllo vale per lo svuotamento ritardato di Bug#34693. Nuovi filtri: `fastcache_warmup_skip_post_types`, `fastcache_warmup_max_urls`, `fastcache_warmup_time_budget`.
     156
    1541571.7.9
    155158Corretto Bug#34693: dopo la pubblicazione o l'aggiornamento di un articolo la cache di pagina viene svuotata una seconda volta, circa un minuto dopo l'ultimo salvataggio (intervallo modificabile con il filtro `fastcache_delayed_purge_seconds`, 0 per disattivarlo). In precedenza una visita arrivata mentre i dati SEO non erano ancora definitivi poteva lasciare in cache una copia con canonical, titolo o descrizione sbagliati (ad esempio il canonical della categoria predefinita invece di quella primaria), che restava servita finché non scadeva o veniva svuotata a mano.
  • fastcache-by-host-it/trunk/fastcache.php

    r3783868 r3788909  
    1717 * Plugin URI:        https://fastcache.host.it/wordpress/
    1818 * Description:       Abilita il tuo sito Wordpress alla prima vera CDN realizzata PER Wordpress e configurata AD-HOC per il tuo sito. Il massimo della velocità senza difficoltà di setup.
    19  * Version:           1.7.9
     19 * Version:           1.7.10
    2020 * Author:            Host.it
    2121 * Author URI:        https://fastcache.host.it/
    … …  
    4545define ( '_WP_EXEC', '1' );
    4646define ( '_FASTCACHE_EXEC', 1 );
    47 define ( 'FASTCACHE_VERSION', '1.7.9' );
     47define ( 'FASTCACHE_VERSION', '1.7.10' );
    4848define ( 'FASTCACHE_FILE_PATH', __FILE__ );
    4949
  • fastcache-by-host-it/trunk/src/Host/admin/class-fastcache-admin.php

    r3783868 r3788909  
    5252         */
    5353        private $inDelayedPurge = false;
     54        /**
     55         * Urls waiting for the warm-up of the current request: warmupAfterPurge() fills it, runWarmupQueue() requests each
     56         * url once at shutdown (Bug#34751: bulk saves of technical records used to trigger hundreds of blocking requests).
     57         */
     58        private static $warmupQueue = [];
     59        private static $warmupHooked = false;
    5460        /**
    5561         * Initialize the class and set its properties.
    … …  
    423429                }
    424430
     431                // Technical records without a public page (Elementor global classes, ...) cannot have a stale page to fix
     432                if (! $this->isVisitablePostType(get_post_type($postId))) {
     433                        return;
     434                }
     435
    425436                /**
    426437                 * Seconds between the last save of a post and its second purge. Return 0 to disable it.
    … …  
    482493                }
    483494
     495                // Technical records without a public page (Elementor global classes, templates, ...) have nothing to warm up.
     496                if ( ! $this->isVisitablePostType( $post->post_type ) ) {
     497                        return;
     498                }
     499
    484500                $urls = [];
    485501                $permalink = get_permalink( $postId );
    … …  
    498514                } ) ) );
    499515
     516                // Queue instead of requesting now: every url is requested once per PHP request, after the last purge of the
     517                // request, and without keeping the saving user waiting (see runWarmupQueue()).
     518                foreach ( $urls as $url ) {
     519                        self::$warmupQueue[ $url ] = true;
     520                }
     521                if ( ! self::$warmupHooked ) {
     522                        self::$warmupHooked = true;
     523                        add_action( 'shutdown', array( __CLASS__, 'runWarmupQueue' ), 20 );
     524                }
     525        }
     526
     527        /**
     528         * Whether a post type has pages visitors can open, so it makes sense to warm up and to purge again later.
     529         * Filter fastcache_warmup_skip_post_types adds or removes types from the default list of skipped ones.
     530         *
     531         * @param string $postType
     532         * @return bool
     533         */
     534        private function isVisitablePostType( $postType ) {
     535                if ( function_exists( 'is_post_type_viewable' ) && ! is_post_type_viewable( $postType ) ) {
     536                        return false;
     537                }
     538                $skip = apply_filters( 'fastcache_warmup_skip_post_types', array( 'elementor_library' ) );
     539
     540                return ! ( is_array( $skip ) && in_array( $postType, $skip, true ) );
     541        }
     542
     543        /**
     544         * Shutdown callback: request the queued warm-up urls once each.
     545         * The response is already sent when it runs; where PHP allows it the connection is closed first, so the editor
     546         * never waits for these requests. Capped in number of urls and in time, so a bulk save cannot keep a worker busy.
     547         *
     548         * @return void
     549         */
     550        public static function runWarmupQueue() {
     551                $urls = array_keys( self::$warmupQueue );
     552                self::$warmupQueue = [];
     553                if ( empty( $urls ) ) {
     554                        return;
     555                }
     556
     557                $max = (int) apply_filters( 'fastcache_warmup_max_urls', 10 );
     558                if ( $max > 0 ) {
     559                        $urls = array_slice( $urls, 0, $max );
     560                }
     561                $deadline = time() + max( 1, (int) apply_filters( 'fastcache_warmup_time_budget', 25 ) );
     562
     563                if ( function_exists( 'fastcgi_finish_request' ) ) {
     564                        fastcgi_finish_request();
     565                } elseif ( function_exists( 'litespeed_finish_request' ) ) {
     566                        litespeed_finish_request();
     567                }
     568
    500569                $ua = 'FastCache-Warmup/' . ( defined( 'FASTCACHE_VERSION' ) ? FASTCACHE_VERSION : '1.7.8' );
    501570                foreach ( $urls as $url ) {
     571                        if ( time() > $deadline ) {
     572                                break;
     573                        }
    502574                        $response = wp_remote_get( $url, [
    503575                                'timeout'     => 45,
Note: See TracChangeset for help on using the changeset viewer.