[wp-trac] [WordPress Trac] #22176: Cache the results of the posts_request_ids query

WordPress Trac noreply at wordpress.org
Thu Jul 21 08:53:02 UTC 2022


#22176: Cache the results of the posts_request_ids query
-------------------------------------------------+-------------------------
 Reporter:  ryan                                 |       Owner:
                                                 |  spacedmonkey
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.1
Component:  Query                                |     Version:  3.4.2
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch 2nd-opinion has-unit-      |     Focuses:
  tests early needs-testing needs-dev-note       |  performance
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 Thanks for your feedback @dd32

 So my plan is the following.

 Release 1.
 Introduce new param, `post_query_cache` for caching, default to false.
 Opt in the following.
 - Main query on page.
 - `WP_Query` in recent posts block / widget.
 - `get_user_data_from_wp_global_styles`
 - `block_core_navigation_get_first_non_empty_navigation`
 - `render_block_core_template_part`
 - `get_block_templates`

 Dev note to explain change.

 Release 2.
 Opt in all other usage of WP_Query in core, baring get_posts.

 Release 3.
 Make `post_query_cache` default to true.

 This is all based on the idea, that as `cache_results` as basically not
 ever cached anything, that developers do not know about it / use it. If
 the patch does use `cache_results` param and we trust this params value,
 then the patch is much easier and we can opt users into this function with
 no issue.

 Caching invalidating is pretty solid as the moment. In my patch the
 biggest pain points where.

 - Sticky posts.
 - Taxonomy queries.
 - Querying by parent, such as media, revision and auto saves.

 It is worth noting that I am willing to risk enabling caching by default.
 But I am trying to de-risk this. If there is an support for enabling by
 default for other committers, I will update the patch.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/22176#comment:33>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list