Performance Field Guide for WordPress 6.1

WordPress 6.1 introduces a number of important performance improvements which will have impact in all aspects. The most significant improvements are done in caching WP_Query
as well as REST API.
Improvements to WP_Query
Database queries in WP_Query being cached is a long wanted feature for many developers and finally a dream come true in WordPress 6.1. A couple of new functions will ensure that users cache and linked objects for menu items are now primed while get_page_by_title
function will from now on use WP_Query
and take the full advantage of all these improvements.
Trac tickets holding these changes: #22176, #55716, #55620, #36905.
Improvements to REST API
Priming caches in a single query will significantly improve Posts controller with several new helper functions but that’s not all. User and comments controller will benefit in a similar way while taxonomy and post type controllers are now going to prepare_links
only when needed. This control over prepare_links
method will be available for custom controllers as well.
Trac tickets holding these changes: #52992, #56019, #56020, #55592, #55593, #55620, #55674, #56272.
Site Health improvements
WordPress 6.1 will have two new Site Health checks – Persistent Object Cache and Page Cache, along with a number of new filters. Find out more in dedicated Dev note.
Trac tickets holding these changes: #56040, #56041.
Improvements to multisite
In WordPress 6.1 the network options functions have been updated to be consistent with other metadata types, support for register_meta
is added, prime caching network options in a single query, string main site ID in network options and more.
Trac tickets holding these changes: #37181, #55802.
Bootstrap/Load
The order of action hooks is slightly changed in order to gain more control over caching behavior, preloading assets and conditionally executing redirects.
Trac ticket holding these changes: #56068.
Improvements to Cache API
Cache API improvements bring validating cache keys in WP_Object_Cache
methods, deleting cache by group and making a number of private cache priming functions public, and thus, available for usage in plugins and themes.
A valid cache key must be either an integer number or a non-empty string. This will prevent silent failing in wp_cache_*()
functions, done by a quick type check and adding a _doing_it_wrong()
message if the string is empty, false
, or null
. Also, a check in update_user_caches()
and clean_user_cache()
will make sure that the email is not empty before being cached or removed from cache. Read more in #56198.
Several private cache priming functions for various object types are now public and plugin and theme authors are encouraged to use these functions to improve the performance of their code by reducing the number of database queries. These functions are:
_prime_post_caches()
_prime_term_caches()
_prime_comment_caches()
_prime_network_caches()
_prime_site_caches()
_get_non_cached_ids()
Read more in #56386.
Introducing wp_cache_flush_group()
function
If you wanted to delete cached item with wp_cache_delete
you had to specify the item’s ID, or you had to flush the entire cache with wp_cache_flush
. WordPress 6.1 introduces a new plugable function called wp_cache_flush_group
which removes all cache items in a group, if the object cache implementation supports it.
Introducing wp_cache_supports()
function
Developers can now detect if their current implementation of an object cache supports flushing by group, by calling wp_cache_supports( $feature )
which returns true if the feature is supported. Third-party object cache plugins can declare a wp_cache_supports()
function and correctly list their supported features:
add_multiple
set_multiple
get_multiple
delete_multiple
flush_runtime
flush_group
Note: The wp_cache_supports()
function replaces and supersedes the wp_cache_supports_group_flush()
function added in #4476.
Read more in #56605.
Media improvements
WordPress 6.1 will add decoding="async"
to image attributes, along with new wp_img_tag_add_decoding_attr()
function and wp_img_tag_add_decoding_attr
filter. Read more in #53232.
Query-attachments AJAX endpoint now caches the parent post objects. Read more in #56037.
WP_Media_List_Table
class will call update_post_parent_caches
function in order to prime parent caches in a single database request. Read more in #56036.
Added caching to wp_count_attachments()
for better consistency with wp_count_posts()
. Read more in #55227.
Avoid duplicated query when retrieving empty posts collections. Read more in #55677.
Post, Post Types improvements
In WordPress 6.1 WP_Posts_List_Table
class will call update_post_author_caches
function in order to prime post author caches in a single database request. Read more in #56100.
A new filter post_class_taxonomies
will allow developers to reduce the number of taxonomies for which classes term classes are generated. Read more in #37114.
Sites running persistent object caching will have result of database queries in _find_post_by_old_slug
and _find_post_by_old_date
functions, cached. Read more in #36723.
Editor
Additional build task copy:block-json
will convert and store all block.json
files in a single blocks-json.php
which will prevent all of this from happening for every block on each page load.
Trac ticket holding these changes: #55005.
Database
Identifiers (such as Table and Field names) are escaped with the %i
placeholder which will prevent SQL Injection Vulnerabilities and provide a small performance improvement.
Trac ticket holding these changes: #52506.
Other performance improvements
Administration
Performance of WP_List_Table::get_column_info()
is improved by adding the primary column to the cached header values (#34564).
Cron API
In 6.1 wp-cron will be non-blocking for LiteSpeed LSAPI (#54668).
Taxonomy
Retain default term option when unregistering taxonomies and adjustments to handling default terms for custom taxonomies (#54472).
Themes
Two new actions are wrapping the process of loading a template file (load_template
) – wp_before_load_template
and wp_after_load_template
(#54541).
Script loader
New filter wp_preload_resources
enables resource preloading with rel='preload'
(#42438).
Users
Prime user meta in WP_User_Query (#55594).
Thanks to @spacedmonkey, @tweetythierry, and @tillkruess for peer review.
Trac tickets holding these changes: #22176, #55716, #55620, #36905.
nnnnImprovements to REST API
nnnnPriming caches in a single query will significantly improve Posts controller with several new helper functions but that's not all. User and comments controller will benefit in a similar way while taxonomy and post type controllers are now going to prepare_links
only when needed. This control over prepare_links
method will be available for custom controllers as well.
Trac tickets holding these changes: #52992, #56019, #56020, #55592, #55593, #55620, #55674, #56272.
nnnnSite Health improvements
nnnnWordPress 6.1 will have two new Site Health checks - Persistent Object Cache and Page Cache, along with a number of new filters. Find out more in dedicated Dev note.
nnnnTrac tickets holding these changes: #56040, #56041.
nnnnImprovements to multisite
nnnnIn WordPress 6.1 the network options functions have been updated to be consistent with other metadata types, support for register_meta
is added, prime caching network options in a single query, string main site ID in network options and more.
Trac tickets holding these changes: #37181, #55802.
nnnnBootstrap/Load
nnnnThe order of action hooks is slightly changed in order to gain more control over caching behavior, preloading assets and conditionally executing redirects.
nnnnTrac ticket holding these changes: #56068.
nnnnImprovements to Cache API
nnnnCache API improvements bring validating cache keys in WP_Object_Cache
methods, deleting cache by group and making a number of private cache priming functions public, and thus, available for usage in plugins and themes.
A valid cache key must be either an integer number or a non-empty string. This will prevent silent failing in wp_cache_*()
functions, done by a quick type check and adding a _doing_it_wrong()
message if the string is empty, false
, or null
. Also, a check in update_user_caches()
and clean_user_cache()
will make sure that the email is not empty before being cached or removed from cache. Read more in #56198.
Several private cache priming functions for various object types are now public and plugin and theme authors are encouraged to use these functions to improve the performance of their code by reducing the number of database queries. These functions are:
nnnn- n
_prime_post_caches()
nnnn_prime_term_caches()
nnnn_prime_comment_caches()
nnnn_prime_network_caches()
nnnn_prime_site_caches()
nnnn_get_non_cached_ids()
n
Read more in #56386.
nnnnIntroducing wp_cache_flush_group()
function
nnnnIf you wanted to delete cached item with wp_cache_delete
you had to specify the item's ID, or you had to flush the entire cache with wp_cache_flush
. WordPress 6.1 introduces a new plugable function calledu00a0wp_cache_flush_group
which removes all cache items in a group, if the object cache implementation supports it.
Introducing wp_cache_supports()
function
nnnnDevelopers can now detect if their current implementation of an object cache supports flushing by group, by calling wp_cache_supports( $feature )
which returns true if the feature is supported. Third-party object cache plugins can declare a wp_cache_supports()
function and correctly list their supported features:
- n
add_multiple
nnnnset_multiple
nnnnget_multiple
nnnndelete_multiple
nnnnflush_runtime
nnnnflush_group
n
Note: The wp_cache_supports()
function replaces and supersedes the wp_cache_supports_group_flush()
function added in #4476.
Read more in #56605.
nnnnMedia improvements
nnnnWordPress 6.1 will add decoding="async"
to image attributes, along with new wp_img_tag_add_decoding_attr()
function and wp_img_tag_add_decoding_attr
filter. Read more in #53232.
Query-attachments AJAX endpoint now caches the parent post objects. Read more in #56037.
nnnnWP_Media_List_Table
class will call update_post_parent_caches
function in order to prime parent caches in a single database request. Read more in #56036.
Added caching to wp_count_attachments()
for better consistency with wp_count_posts()
. Read more in #55227.
Avoid duplicated query when retrieving empty posts collections. Read more in #55677.
nnnnPost, Post Types improvements
nnnnIn WordPress 6.1 WP_Posts_List_Table
class will call update_post_author_caches
function in order to prime post author caches in a single database request. Read more in #56100.
A new filter post_class_taxonomies
will allow developers to reduce the number of taxonomies for which classes term classes are generated. Read more in #37114.
Sites running persistent object caching will have result of database queries in _find_post_by_old_slug
and _find_post_by_old_date
functions, cached. Read more in #36723.
Editor
nnnnAdditional build task copy:block-json
will convert and store all block.json
files in a single blocks-json.php
which will prevent all of this from happening for every block on each page load.
Trac ticket holding these changes: #55005.
nnnnDatabase
nnnnIdentifiers (such as Table and Field names) are escaped with the %i
placeholder which will prevent SQL Injection Vulnerabilities and provide a small performance improvement.
Trac ticket holding these changes: #52506.
nnnnOther performance improvements
nnnnAdministration
nnnnPerformance of WP_List_Table::get_column_info()
is improved by adding the primary column to the cached header values (#34564).
Cron API
nnnnIn 6.1 wp-cron will be non-blocking for LiteSpeed LSAPI (#54668).
nnnnTaxonomy
nnnnRetain default term option when unregistering taxonomies and adjustments to handling default terms for custom taxonomies (#54472).
nnnnThemes
nnnnTwo new actions are wrapping the process of loading a template file (load_template
) - wp_before_load_template
and wp_after_load_template
(#54541).
Script loader
nnnnNew filter wp_preload_resources
enables resource preloading with rel='preload'
(#42438).
Users
nnnnPrime user meta in WP_User_Query (#55594).
nnnnThanks to @spacedmonkey, @tweetythierry, and @tillkruess for peer review.
nnn#6-1, #dev-notes, #dev-notes-6-1, #field-guide, #performance","contentFiltered":"WordPress 6.1 introduces a number of important performance improvements which will have impact in all aspects. The most significant improvements are done in caching WP_Query
as well as REST API.
Improvements to WP_Query
nnnnDatabase queries in WP_Query being cached is a long wanted feature for many developers and finally a dream come true in WordPress 6.1. A couple of new functions will ensure that users cache and linked objects for menu items are now primed while get_page_by_title
function will from now on use WP_Query
and take the full advantage of all these improvements.
Trac tickets holding these changes: #22176, #55716, #55620, #36905.
nnnnImprovements to REST API
nnnnPriming caches in a single query will significantly improve Posts controller with several new helper functions but thatu2019s not all. User and comments controller will benefit in a similar way while taxonomy and post type controllers are now going to prepare_links
only when needed. This control over prepare_links
method will be available for custom controllers as well.
Trac tickets holding these changes: #52992, #56019, #56020, #55592, #55593, #55620, #55674, #56272.
nnnnSite Health improvements
nnnnWordPress 6.1 will have two new Site Health checks u2013 Persistent Object Cache and Page Cache, along with a number of new filters. Find out more in dedicated Dev note.
nnnnTrac tickets holding these changes: #56040, #56041.
nnnnImprovements to multisite
nnnnIn WordPress 6.1 the network options functions have been updated to be consistent with other metadata types, support for register_meta
is added, prime caching network options in a single query, string main site ID in network options and more.
Trac tickets holding these changes: #37181, #55802.
nnnnBootstrap/Load
nnnnThe order of action hooks is slightly changed in order to gain more control over caching behavior, preloading assets and conditionally executing redirects.
nnnnTrac ticket holding these changes: #56068.
nnnnImprovements to Cache API
nnnnCache API improvements bring validating cache keys in WP_Object_Cache
methods, deleting cache by group and making a number of private cache priming functions public, and thus, available for usage in plugins and themes.
A valid cache key must be either an integer number or a non-empty string. This will prevent silent failing in wp_cache_*()
functions, done by a quick type check and adding a _doing_it_wrong()
message if the string is empty, false
, or null
. Also, a check in update_user_caches()
u00a0andu00a0clean_user_cache()
will make sure that the email is not empty before being cached or removed from cache. Read more in #56198.
Several private cache priming functions for various object types are now public and plugin and theme authors are encouraged to use these functions to improve the performance of their code by reducing the number of database queries. These functions are:
nnnn_prime_post_caches()
nnnn_prime_term_caches()
nnnn_prime_comment_caches()
nnnn_prime_network_caches()
nnnn_prime_site_caches()
nnnn_get_non_cached_ids()
n
Read more in #56386.
nnnnIntroducing wp_cache_flush_group()
function
nnnnIf you wanted to delete cached item with wp_cache_delete
you had to specify the itemu2019s ID, or you had to flush the entire cache with wp_cache_flush
. WordPress 6.1 introduces a new plugable function calledu00a0wp_cache_flush_group
which removes all cache items in a group, if the object cache implementation supports it.
Introducing wp_cache_supports()
function
nnnnDevelopers can now detect if their current implementation of an object cache supports flushing by group, by callingu00a0wp_cache_supports( $feature )
u00a0which returns true if the feature is supported. Third-party object cache plugins can declare au00a0wp_cache_supports()
u00a0function and correctly list their supported features:
add_multiple
nnnnset_multiple
nnnnget_multiple
nnnndelete_multiple
nnnnflush_runtime
nnnnflush_group
n
Note: Theu00a0wp_cache_supports()
u00a0function replaces and supersedes theu00a0wp_cache_supports_group_flush()
u00a0function added in #4476.
Read more in #56605.
nnnnMedia improvements
nnnnWordPress 6.1 will add decoding="async"
u00a0to image attributes, along with new wp_img_tag_add_decoding_attr()
function and wp_img_tag_add_decoding_attr
filter. Read more in #53232.
Query-attachments AJAX endpoint now caches the parent post objects. Read more in #56037.
nnnnWP_Media_List_Table
u00a0class will call update_post_parent_caches
u00a0function in order to prime parent caches in a single database request. Read more in #56036.
Added caching tou00a0wp_count_attachments()
for better consistency withu00a0wp_count_posts()
. Read more in #55227.
Avoid duplicated query when retrieving empty posts collections. Read more in #55677.
nnnnPost, Post Types improvements
nnnnIn WordPress 6.1 WP_Posts_List_Table
u00a0class will call update_post_author_caches
u00a0function in order to prime post author caches in a single database request. Read more in #56100.
A new filter post_class_taxonomies
will allow developers to reduce the number of taxonomies for which classes term classes are generated. Read more in #37114.
Sites running persistent object caching will have result of database queries inu00a0_find_post_by_old_slug
u00a0andu00a0_find_post_by_old_date
u00a0functions, cached. Read more in #36723.
Editor
nnnnAdditional build task copy:block-json
will convert and store all block.json
files in a single blocks-json.php
which will prevent all of this from happening for every block on each page load.
Trac ticket holding these changes: #55005.
nnnnDatabase
nnnnIdentifiers (such as Table and Field names) are escaped with theu00a0%i
u00a0placeholder which will prevent SQL Injection Vulnerabilities and provide a small performance improvement.
Trac ticket holding these changes: #52506.
nnnnOther performance improvements
nnnnAdministration
nnnnPerformance ofu00a0WP_List_Table::get_column_info()
u00a0is improved by adding the primary column to the cached header values (#34564).
Cron API
nnnnIn 6.1 wp-cron will be non-blocking for LiteSpeed LSAPI (#54668).
nnnnTaxonomy
nnnnRetain default term option when unregistering taxonomies and adjustments to handling default terms for custom taxonomies (#54472).
nnnnThemes
nnnnTwo new actions are wrapping the process of loading a template file (load_template
) u2013 wp_before_load_template
and wp_after_load_template
(#54541).
Script loader
nnnnNew filter wp_preload_resources
enables resource preloading with rel='preload'
(#42438).
Users
nnnnPrime user meta in WP_User_Query (#55594).
nnnnThanks tou00a0@spacedmonkey, @tweetythierry, and @tillkruessu00a0for peer review.
n ","permalink":"https://make.wordpress.org/core/2022/10/11/performance-field-guide-for-wordpress-6-1/","unixtime":1665498807,"unixtimeModified":1665500913,"entryHeaderMeta":"","linkPages":"","footerEntryMeta":"","tagsRaw":"6.1, dev-notes, dev-notes-6.1, field guide, performance","tagsArray":[{"label":"6.1","count":67,"link":"https://make.wordpress.org/core/tag/6-1/"},{"label":"dev-notes","count":445,"link":"https://make.wordpress.org/core/tag/dev-notes/"},{"label":"dev-notes-6.1","count":31,"link":"https://make.wordpress.org/core/tag/dev-notes-6-1/"},{"label":"field guide","count":22,"link":"https://make.wordpress.org/core/tag/field-guide/"},{"label":"performance","count":131,"link":"https://make.wordpress.org/core/tag/performance/"}],"loginRedirectURL":"https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fcore%2F2022%2F10%2F11%2Fperformance-field-guide-for-wordpress-6-1%2F&locale=en_US","hasPrevPost":false,"prevPostTitle":"","prevPostURL":"","hasNextPost":false,"nextPostTitle":"","nextPostURL":"","commentsOpen":true,"is_xpost":false,"editURL":null,"postActions":"","comments":[{"type":"comment","id":"43920","postID":"99318","postTitleRaw":"Performance Field Guide for WordPress 6.1","cssClasses":"comment byuser comment-author-shetheliving odd alt thread-odd thread-alt depth-1","parentID":"0","contentRaw":"+make.wordpress.org/performance/","contentFiltered":" n","permalink":"https://make.wordpress.org/core/2022/10/11/performance-field-guide-for-wordpress-6-1/#comment-43920","unixtime":1665503304,"loginRedirectURL":"https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fcore%2F2022%2F10%2F11%2Fperformance-field-guide-for-wordpress-6-1%2F%23comment-43920&locale=en_US","approved":true,"isTrashed":false,"prevDeleted":"","editURL":null,"depth":1,"commentDropdownActions":"","commentFooterActions":" ","commentTrashedActions":"","mentions":[],"mentionContext":"","commentCreated":"1665503304","hasChildren":false,"userLogin":"shetheliving","userNicename":"shetheliving"}],"postFormat":"standard","postMeta":{"isSticky":false},"postTerms":{"category":[{"label":"General","count":2084,"link":"https://make.wordpress.org/core/category/general/"}],"post_tag":[{"label":"6.1","count":67,"link":"https://make.wordpress.org/core/tag/6-1/"},{"label":"dev-notes","count":445,"link":"https://make.wordpress.org/core/tag/dev-notes/"},{"label":"dev-notes-6.1","count":31,"link":"https://make.wordpress.org/core/tag/dev-notes-6-1/"},{"label":"field guide","count":22,"link":"https://make.wordpress.org/core/tag/field-guide/"},{"label":"performance","count":131,"link":"https://make.wordpress.org/core/tag/performance/"}],"post_format":[]},"pluginData":[],"isPage":false,"mentions":["spacedmonkey","tweetythierry","tillkruess"],"mentionContext":"","isTrashed":false,"userLogin":"milana_cap","userNicename":"milana_cap"}]