Make WordPress Core

Opened 6 months ago

Closed 7 weeks 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 (9)

#1 follow-up: @dannythedog
7 weeks 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.


7 weeks ago
#2

  • Keywords has-patch added

#3 in reply to: ↑ 1 @akshat2802
7 weeks 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
7 weeks 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
7 weeks ago

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

#6 @westonruter
7 weeks ago

  • Component changed from General to Site Health

#7 @westonruter
7 weeks ago

Follow-up ticket: #64370

@westonruter commented on PR #10598:


7 weeks ago
#8

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

I've filed this as Core-64370.

#9 @westonruter
7 weeks 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.

Note: See TracTickets for help on using tickets.