Opened 2 years ago
Closed 20 months ago
#58384 closed enhancement (duplicate)
locate_template calls file_exists a lot
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | high | |
Severity: | normal | Version: | 4.7 |
Component: | Themes | Keywords: | |
Focuses: | performance | Cc: |
Description
The function locate_template
calls file_exists
three times for every each template name. As locate_template can be called multiple times on a page request for both classic and block themes, this can result in poor performance for this function.
As file_exists
can be an expensive function to run, as the file lookup on file system can be slow, some level of caching should be added to this function.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Thanks for opening this ticket @spacedmonkey! Worth looking into for sure.
file_exists results are cached by PHP:
So while this reduces the impact of filesystem calls, having a cache for the results of the
foreach()
loop may be useful here.Have you run any tests to see how much of a performance improvement a cache of these results brings?