Make WordPress Core

Opened 2 years ago

Closed 22 months ago

#55666 closed enhancement (invalid)

Add caching to get_block_templates function

Reported by: spacedmonkey's profile spacedmonkey Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.9
Component: Themes Keywords: needs-patch
Focuses: performance Cc:


The function get_block_templates now calls the WP_Query for every call. This means that every time it requested, it can result in a query to the database. This function should have some level of caching to save duplicate queries on a page load.

Attachments (1)

Screenshot 2022-05-03 at 16.58.01.png (1.0 MB) - added by spacedmonkey 2 years ago.

Download all attachments as: .zip

Change History (4)

#1 @peterwilsoncc
2 years ago

Is it worth working on #22176 during the 6.1 cycle to solve this for multiple functions rather than one by one?

It would be a heap more work but ultimately less effort than to keep adding caching to all the the functions making use of WP_Query.

#2 @spacedmonkey
2 years ago

@peterwilsoncc Great minds think alike.

I had the same thought. But I was thinking have a flag, that defaults to false for caching results. That way we can opt-in usage of WP_Query in core. That way we can roll it out slowly. For this ticket for example, it would simply mean, activating the flag.


#3 @spacedmonkey
22 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This ticket is now invalid, now that #22176 has been merged.

Note: See TracTickets for help on using tickets.