New cache Site Health checks in WordPress 6.1

As part of the WordPress 6.1 release, the Performance Team has added two Site Health checks (Persistent Object Cache and Page Cache). These checks were previously tested in the Performance Lab plugin. You can read more about them in the original proposal.

Both checks will run only in a production environment.

Persistent Object Cache

This new check determines whether the site uses a persistent object cache or not and recommends it if it makes sense for the site. It also links to a support resource created for the check.

A few filters have been included aiming for hosting providers to provide more specific steps regarding their environment.

Hosts may use the site_status_persistent_object_cache_url filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. to replace the original WordPress guide with their own guide.

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

Hosts may use the site_status_persistent_object_cache_notes filter to customize the notes to recommend their preferred object cache solution.

/**
 * 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;
} );

The site_status_persistent_object_cache_thresholds filter allows modifying the thresholds above WordPress considers using a persistent object cache beneficial.

/**
 * 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;
} );

Alternatively, site_status_should_suggest_persistent_object_cache is a short-circuit filter that allows using entirely custom logic to determine whether a persistent object cache would make sense for the site.

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

For additional context on this new check, see #56040.

Full Page Cache

This new check determines whether the site is using a full page cache solution and if the response time is acceptable.

It also adds a couple of filters aiming for hosting companies to customize the response threshold and add their own cache headers to be detected.

The site_status_good_response_time_threshold filter allows modifying the current threshold of 600ms. Everything below this will be considered acceptable.

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

Additional custom cache headers ( and optionally their verification callbacks) can be added through the site_status_page_cache_supported_cache_headers filter.

/**
 * 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;
});

For additional context on this new check, see #56041.

Thanks to @flixos90, @milana_cap, @spacedmonkey for peer review, and @pushpakpop for the code examples.

#6-1, #core-site-health, #dev-notes, #dev-notes-6-1, #performance, #performance-lab, #site-health

Proposal: Persistent Object Cache and Full Page Cache Site Health Checks

This proposal seeks to integrate two new Site Health checks for Persistent Object Cache and Full Page Cache into WordPress coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress., targeting the WordPress 6.1 release.

Context

Providing valuable recommendations for site owners is crucial to improving WordPress performance. These two modules are the first in a series of Site Health modules that the performance team is working on. Acknowledging performance problems is the first step to solving them.

The modules were originally proposed and developed by members of the performance team and are available as modules inside the Performance Lab plugin.

Project update

Development of the features has been ongoing in the Performance Lab plugin repository on GitHub, where they have been implemented as: 

The recently released version 1.2.0 of the Performance Lab plugin contains both modules in a state that is ready to merge into core. 

The team is currently migrating the module code into WordPress core patches in 2 TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. tickets:

  • Persistent Object Cache Health Check from performance pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party to core (#56040)
  • Port Audit Full Page Cache from performance plugin to core (#56041)

Any reviews and feedback on the core patches would be greatly appreciated.

Customizing the audits

We’ve added a series of filters to make messaging and suggestions customizable. These filters can be used by hosting providers to provide their own personalized suggestions on how to address the Site Health feedback.

Persistent Object Cache filters

Hosts may want to replace the notes to recommend their preferred object caching solution:

apply_filters( 'site_status_persistent_object_cache_notes', $notes, $available_services );

Hosts may want to replace the original link to WordPress documentation with a link to  their own guide:

apply_filters( 'site_status_persistent_object_cache_url',  __('https://wordpress.org/support/article/optimization/#object-caching' ));

Hosts or site owners may want to bypass thresholds and force suggestions, or filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. them to determine whether to suggest the use of a persistent object cache:

apply_filters( 'site_status_suggest_persistent_object_cache', false );
apply_filters(
    'site_status_persistent_object_cache_thresholds',
    array(
        'alloptions_count' => 500,
        'alloptions_bytes' => 100000,
        'comments_count'   => 1000,
        'options_count'    => 1000,
        'posts_count'      => 1000,
        'terms_count'      => 1000,
        'users_count'      => 1000,
    )
);

Full Page Cache filters

Developers can filter the threshold below which a response time is considered good:

apply_filters( 'page_cache_good_response_time_threshold', 600 );

Testing and feedback

You can test the modules in v1.2.0 or later of the Performance Lab plugin. Both modules should be enabled by default, but you can double-check that they are enabled in Settings > Performance:

Once enabled, you can view the test results on the Site Health Status screen at Tools > Site Health > Status.

We encourage you to test these modules (and others) from the Performance Lab Plugin, report any bugs in our GitHub repository, or contribute with fixes and ideas. You can also share any feedback, concerns, or questions to improve these features further in the comments.

Thanks to @mxbclang and @flixos90 for peer review.

#6-1, #core-site-health, #performance, #performance-lab, #site-health

Dev chat summary, August 11, 2021

@sergeybiryukov stepped up to lead this agenda-less meeting. Big thank you!

Highlighted blogblog (versus network, site) posts

From @audrasjb, another A Week in Core post highlights the moving parts of CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. and recognizes a week’s worth of contributors at a time.

From @sarayourfriend provides an update on the native TypeScript proposal announcing that the GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ project supports native TypeScript.

From @notlaura comes a Call for CSS Contributors, a carryover and reminder from last week. Their next weekly work session is August 12, 2021 at 21:00 UTC in #core-css.

From @chanthaboune, participate in the WordPress 5.8 ‘Tatum’ Retrospective. Feedback is due on August 15th and is greatly appreciated to make future releases even better.

From @webcommsat comes a helpful post for spreading the word about 5.8. In this post, you will find social posts you can share and adapt on Twitter and Facebook.

From @annezazu, follow the latest call for testing through the FSE Outreach Program. It’s focused on using the navigation blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. to build out a HigherEd themed headerHeader The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes. with three weeks to share you feedback.

From @annezazu comes a reminder to help shape the future of theme design. If you’re a block theme author or have explored that space, please share your responses by August 15th and know they are each greatly appreciated. 

Finally, catch up with the previous episodes of WP Briefing. The podcast will return in September!

Component maintainers

Reporting in on Build/Test tools, @sergeybiryukov shared that, as of last weekend, WordPress test suite is compatible with PHPUnit 8 & 9, and runs tests on PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher 8.1 betaBeta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process. (scheduled for release in November). Props to @jrf and @hellofromtonya for all the fixes and improvements that made it possible!  See ticketticket Created for both bug reports and feature development on the bug tracker. #46149 for more details.

Reporting on Date/Time, I18Ni18n Internationalization, or the act of writing and preparing code to be fully translatable into other languages. Also see localization. Often written with a lowercase i so it is not confused with a lowercase L or the numeral 1. Often an acquired skill., Permalinks, @sergeybiryukov said that there’s no major news this week.

Reporting on General, @sergeybiryukov shared that work has started on making various compatibility fixes for PHP 8.1. Thanks @jrf, again!  See ticket #53635 for more details.

Open Floor

Considering #49728 for the 5.9 release. Raised by @hareesh-pillai.

Since the topic of compatibility with the latest PHP versions came up, Hareesh flagged that it would make sense to include this additional ticket after it was pushed from 5.6.

Next step: @hellofromtonya moved it to the 5.9 milestone.

Invitation to contribute to testing. Raised by @hellofromtonya.

Anyone interested in contributing to testing including attempting to reproduce problems, gathering testing information (such as testing steps, acceptance criteria, dependencies), user testing, and automated testing, you’re invited to join us in #core-test channel.

Checking in on a dev notedev note Each important change in WordPress Core is documented in a developers note, (usually called dev note). Good dev notes generally include a description of the change, the decision that led to this change, and a description of how developers are supposed to work with that change. Dev notes are published on Make/Core blog during the beta phase of WordPress release cycle. Publishing dev notes is particularly important when plugin/theme authors and WordPress developers need to be aware of those changes.In general, all dev notes are compiled into a Field Guide at the beginning of the release candidate phase. related to pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party folks finding issues with PHPUnit updates. Raised by @jeffpaul.

@hellofromtonya and @jrf quickly chimed in to say that a dev note is in progress with an ideal publish date of next week. The quick TL;DR is:

  • Fixture methods changed in the WP test cases, i.e. changed to snake_case
  • Wrappers for the snake_case will be backported for extenders who are testing against versions other than trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision..
  • Once those backports happen, then the fixture methods in your tests need to be updated for testing against trunk.

To help extenders, command-line messages will be added as well to alert and guide devs.

Bumping the ACCEPTABLE_PHP and SUPPORTED_PHP versions in light of PHP 7.3 support ending in 3 months. Raised by @hareesh-pillai.

@sergeybiryukov recommended that this be raised as a discussion topic in the next #core-site-health meeting. He also shared that he felt it was a bit too early to bump the recommended version to PHP 8.0, as there is still ongoing work to make it more compatible.

#dev-chat, #summary