當(dāng)前位置:首頁(yè)>WordPress資訊>WordPress 6.1 的站點(diǎn)健康檢查新增緩存檢查

WordPress 6.1 的站點(diǎn)健康檢查新增緩存檢查

作為 WordPress 6.1 版本的一部分,性能團(tuán)隊(duì)添加了兩項(xiàng)站點(diǎn)健康檢查(持久對(duì)象緩存和頁(yè)面緩存。這些檢查之前在Performance Lab 插件中進(jìn)行了測(cè)試。您可以在原始提案中閱讀更多關(guān)于它們的信息。

這兩項(xiàng)檢查都將僅在生產(chǎn)環(huán)境中運(yùn)行。

持久對(duì)象緩存

這項(xiàng)新檢查確定站點(diǎn)是否使用持久對(duì)象緩存,并在對(duì)站點(diǎn)有意義時(shí)推薦它。它還鏈接到為檢查創(chuàng)建的支持資源。

已包含一些過濾器,旨在讓托管服務(wù)提供商提供有關(guān)其環(huán)境的更具體的步驟。

管理員可以使用site_status_persistent_object_cache_url?過濾器將原始 WordPress 指南替換為他們自己的指南。

/**
 * Filter the Persistent object cache URL.
 */
add_filter( 'site_status_persistent_object_cache_url', function() {
    return 'https://awesomewphosting.com/optimization/persistent-object-cache';
} );

還可以使用site_status_persistent_object_cache_notes過濾器自定義注釋以推薦他們首選的對(duì)象緩存解決方案。

/**
 * Update the persistent object cache notes.
 */
add_filter( 'site_status_persistent_object_cache_notes', function( $notes ) {
    $notes = __( 'The updated notes can go here as text.', 'text-domain' );
 
    return $notes;
} );

新增的 site_status_persistent_object_cache_thresholds過濾器允許修改 WordPress 認(rèn)為使用持久對(duì)象緩存有益的閾值。

/**
 * Override the whole $thresholds array, or any specific indexes as required.
 */
add_filter( 'site_status_persistent_object_cache_thresholds', function( $thresholds ) {
    $thresholds = array(
        'alloptions_count' => 600,
        'alloptions_bytes' => 200000,
        'comments_count'   => 2000,
        'options_count'    => 2000,
        'posts_count'      => 2000,
        'terms_count'      => 2000,
        'users_count'      => 2000,
    );
 
    return $thresholds;
} );

或者,site_status_should_suggest_persistent_object_cache是一個(gè)短路(short-circuit)過濾器,它允許使用完全自定義的邏輯來(lái)確定持久對(duì)象緩存是否對(duì)站點(diǎn)有意義。

/**
 * Opt in for suggesting the persistent object cache
 */
add_filter( 'site_status_should_suggest_persistent_object_cache', '__return_true' );

有關(guān)此新檢查的其他上下文,請(qǐng)參閱#56040

整頁(yè)緩存

這項(xiàng)新檢查確定站點(diǎn)是否正在使用整頁(yè)緩存解決方案以及響應(yīng)時(shí)間是否可以接受。

它還添加了一些過濾器,旨在讓托管公司自定義響應(yīng)閾值并添加自己的緩存標(biāo)頭以進(jìn)??行檢測(cè)。

新增的 site_status_good_response_time_threshold過濾器允許修改 600 毫秒的當(dāng)前閾值。低于此值的所有內(nèi)容都將被認(rèn)為是可以接受的。

/**
 * Filter the response time threshold
 */
add_filter( 'site_status_good_response_time_threshold', function() {
    return 200;
} );

可以通過site_status_page_cache_supported_cache_headers過濾器添加其他自定義緩存標(biāo)頭(以及可選的驗(yàn)證回調(diào))。

/**
 * Filter the page cache supported cache headers
 * $cache_headers contains List of client caching headers and their (optional) verification callbacks.
 */
add_filter( 'site_status_page_cache_supported_cache_headers', function( $cache_headers  ) {
    // Add new header to the existing list.
    $cache_headers['cf-cache-status'] = static function ( $header_value ) {
        return false !== strpos( strtolower( $header_value ), 'hit' );
    };
    return $cache_headers;
});

有關(guān)此新檢查的其他上下文,請(qǐng)參閱#56041

聲明:本站所有文章,如無(wú)特殊說明或標(biāo)注,均為本站原創(chuàng)發(fā)布。任何個(gè)人或組織,在未征得本站同意時(shí),禁止復(fù)制、盜用、采集、發(fā)布本站內(nèi)容到任何網(wǎng)站、書籍等各類媒體平臺(tái)。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。

給TA打賞
共{{data.count}}人
人已打賞
歡迎關(guān)注WordPress大學(xué)公眾號(hào) WPDAXUE
WordPress資訊

WordPress 6.1 新增的默認(rèn)主題2023功能特色詳解

2022-10-6 17:39:25

WordPress開發(fā)WordPress資訊

WordPress 6.1 引入了填充、邊距和塊間隙的預(yù)設(shè)值

2022-10-9 10:10:50

0 條回復(fù) A文章作者 M管理員
    暫無(wú)討論,說說你的看法吧
?
個(gè)人中心
購(gòu)物車
優(yōu)惠劵
今日簽到
有新私信 私信列表
搜索

鹤壁市| 溧水县| 浦东新区| 安国市| 定远县| 隆尧县| 霞浦县| 息烽县| 舞钢市| 廉江市| 彭州市| 邻水| 那坡县| 来宾市| 新乡市| 延吉市| 沂源县| 湘潭市| 郑州市| 东平县| 资溪县| 牡丹江市| 北安市| 乌兰浩特市| 威海市| 林西县| 南投市| 颍上县| 阿瓦提县| 斗六市| 潍坊市| 丹阳市| 息烽县| 蒙城县| 汶川县| 太康县| 乌兰县| 天等县| 来安县| 平果县| 鸡西市|