Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#55666 closed enhancement (invalid)

Add caching to get_block_templates function

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

Description

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 4 years ago.

Download all attachments as: .zip

Change History (4)

#1 @peterwilsoncc
4 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
4 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.

Thoughts

#3 @spacedmonkey
4 years ago

  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status newclosed

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

Note: See TracTickets for help on using tickets.