get_page_templates consumes too much IO for each page request
-
Hi,
Please add a transient cache for
get_page_templates
if it sounds ok to you.I presently have a auto-scaling setup with a network drive (AWS EFS) and this slows down each page considerably since opcache does not cache file reads. Using
fatrace
I observed that php files in my theme were constantly being Opened->Read->Closed by PHP-FPM. I traced it back to this plugin.My original time reported by query-monitor was 2.45 seconds.
After I added a transient cache it improved to 1.14 seconds.It’s uncommon for page templates to be added/removed frequently but if you add a transient here it would need to be documented to prevent confusion.
Example:
$templates = get_transient('ao_crit_page_tpls'); if(!$templates) { $templates = wp_get_theme()->get_page_templates(); set_transient('ao_crit_page_tpls', $templates, 3600); }
- The topic ‘get_page_templates consumes too much IO for each page request’ is closed to new replies.