Make WordPress Core

Opened 11 months ago

Closed 6 months ago

Last modified 4 months ago

#63748 closed feature request (fixed)

Site Health test for page caching lacks headers for detection

Reported by: vincentbreton's profile vincentbreton Owned by: westonruter's profile westonruter
Milestone: 7.0 Priority: normal
Severity: normal Version: 6.1
Component: Site Health Keywords: has-patch
Focuses: performance Cc:

Description

It would be useful if WordPress could check for the presence of HTTP headers such as X-Cache or X-Xtrem-Cache to detect active server-side caches.

For modern configurations, especially on high-performance hosting providers, this alert is unnecessarily alarming.

The Site Health Status displays an unnecessarily alarming error.

Change History (10)

#1 follow-up: @dannythedog
6 months ago

I’m seeing the same behavior on my site.
I’m running WordPress on a VPS with Nginx FastCGI cache and Cloudflare in front. Full page cache is handled at the server level, not by a plugin.

Site Health still reports “Page cache is not detected but the server response time is OK”, even though TTFB is around 50ms after enabling FastCGI cache.

The HTML response from my origin includes a header like:

X-Cache-Status: HIT

but this header is not part of the list that WP_Site_Health::get_page_cache_headers() checks for. It would be helpful if Site Health could also treat headers like X-Cache / X-Cache-Status as a signal that full page cache is enabled, or provide an easier way (filter) to add custom cache headers for this test.

This setup follows the official performance documentation for server-side caching (Nginx FastCGI cache), but the Site Health check still looks “red” which is confusing for users.

This ticket was mentioned in PR #10598 on WordPress/wordpress-develop by @akshat2802.


6 months ago
#2

  • Keywords has-patch added

#3 in reply to: ↑ 1 @akshat2802
6 months ago

Replying to dannythedog:

This setup follows the official performance documentation for server-side caching (Nginx FastCGI cache), but the Site Health check still looks “red” which is confusing for users.

Agree with you @dannythedog
Sites using Nginx FastCGI cache, Cloudflare CDN, Varnish, or Apache mod_cache currently show "Page cache is not detected" in Site Health, even when these caching solutions are properly configured and functioning. This creates confusion for site administrators who have followed WordPress's official performance guidance.

Here are some support links:

Here is the PR to add some common headers in core function: https://github.com/WordPress/wordpress-develop/pull/10598

Also, we have a WP filter that can add custom cache headers that need to be considered at the time of checking site health. Ref: https://developer.wordpress.org/reference/hooks/site_status_page_cache_supported_cache_headers/

add_filter( 'site_status_page_cache_supported_cache_headers', function( $cache_headers ) {
    
    $cache_headers['x-my-cache-status'] = function( $header_value ) {
        return in_array( 
            strtoupper( $header_value ), 
            array( 'HIT', 'BYPASS', 'EXPIRED' ) 
        );
    };
    
    return $cache_headers;
} );

#4 @westonruter
6 months ago

  • Focuses performance added
  • Milestone changed from Awaiting Review to 7.0
  • Summary changed from site helth status - cache to Site Health test for page caching lacks headers for detection
  • Version changed from 6.8.2 to 6.1

The page cache test for Site Health was added in #54423.

#5 @westonruter
6 months ago

  • Owner set to westonruter
  • Status changed from new to reviewing

#6 @westonruter
6 months ago

  • Component changed from General to Site Health

#7 @westonruter
6 months ago

Follow-up ticket: #64370

@westonruter commented on PR #10598:


6 months ago
#8

the extra examples are icing on the cake and not necessary here.

I've filed this as Core-64370.

#9 @westonruter
6 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 61355:

Site Health: Add common HTTP response headers for page cache detection.

Developed in https://github.com/WordPress/wordpress-develop/pull/10598

Follow-up to [54043].

Props akshat2802, szepeviktor, dmsnell, vincentbreton, dannythedog, westonruter.
See #56041.
Fixes #63748.

#10 @westonruter
4 months ago

In 61711:

Site Health: Improve page cache detection with added header and refined verification logic.

  • Use a more precise regular expression for identifying "HIT" statuses to avoid false positives (e.g., "no-hit").
  • Add specific verification logic for Varnish's X-Varnish header.
  • Use a null value in the header mapping to indicate a header existence check, when no callback is supplied.
  • Improve documentation with links for information about certain headers.

Developed in https://github.com/WordPress/wordpress-develop/pull/10855

Follow-up to [61355], [54043].

Props westonruter, dmsnell.
See #63748.
Fixes #64370.

Note: See TracTickets for help on using tickets.