• Resolved Pratham

    (@pratham2003)


    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);
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    wow pratham2003, that is very interesting, thanks!! if you want, feel free to do a PR on github, I’d be happy to merge (we might want to to make transient expiration filterable, but 1h seems reasonble)!

    frank

    Thread Starter Pratham

    (@pratham2003)

    Cool! thanks for replying soon 🙂

    I’ve created a PR with some modifications, please review these changes.
    https://github.com/futtta/autoptimize/pull/326

    I noticed you had registered an action while clearing autoptimize cache: autoptimize_action_cachepurged.

    I have added code to delete the transient when the above action is triggered.

    • This reply was modified 3 years, 10 months ago by Pratham.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_page_templates consumes too much IO for each page request’ is closed to new replies.