Want to subscribe to topics you're interested in?
Become a Member

Wordpress Cache Enabler Plugin best config?

Discussion in 'Blogs & CMS usage' started by rdan, Feb 4, 2020.

  1. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    I'm confuse if it's the best and optimal config having a header:
    This blog says
    But I'm seeing it on Cached pages, not sure where it is being added?
     
  2. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Yeah cache enabler header is a hit more miss. Best way to test if it's working is if you benchmark/stress test your server and check which processes are loaded nginx and/or php-fpm. If advanced caching is working, then under load most of it will be from nginx and not php-fpm.
     
  3. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    Do you have a WP site with Cache Enabler enabled?
    Would like to view http headers.
     
  4. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Well there's conflicting info from Cody at KeyCDN for cache enabler at Please Explain This | WordPress.org

    and their advanced-cache.php code line at keycdn/cache-enabler also suggests if x-cache-handler wp is set then advanced cache is in use
    PHP:
    // set cache handler header
    header('x-cache-handler: wp');
     
  5. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    So if I get this header:
    My nginx config isn't working as expected / not optimal :/
     
  6. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    no if you get that header means advance caching is working as expected = optimal

    again, best way to test if it's working is if you benchmark/stress test your server and check which processes are loaded nginx and/or php-fpm. If advanced caching is working, then under load most of it will be from nginx and not php-fpm.

    You can see in my thread at https://community.centminmod.com/th...ugins-for-page-load-speed-optimization.15039/ as well.
     
    • Like Like x 1
  7. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    But still goes thru PHP-FPM as you get that header included.
    I tried and stop PHP-FPM and site won't load even the cache files are present.
     
  8. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    PHP has to run to create the initial cache entry. Then advanced cache at Nginx level handles logic of whether to serve from cache or not - the logic is handled by Nginx and not PHP (normal non-advanced mode).
    Code (Text):
    try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    

    where $cache_enabler_uri is defined by
    Code (Text):
        # default html file
        set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';
    
        # webp html file
        if ($http_accept ~* "image/webp") {
            set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index-webp.html';
        }


    again, best way to test if it's working is if you benchmark/stress test your server and check which processes are loaded nginx and/or php-fpm. If advanced caching is working, then under load most of it will be from nginx and not php-fpm.
     
    Last edited: Feb 4, 2020
  9. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    This is the quickest way to test for me :)

    I got it working now after I removed this config:
    Code:
    # webp html file
        if ($http_accept ~* "image/webp") {
            set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index-webp.html';
        }
    Cached files are directly served by Nginx, even PHP-FPM was stop.. site works fine with cached files already populated.
     
  10. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    And this article is correct:
    WordPress Cache Enabler Plugin - KeyCDN Support

     
  11. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    that is required otherwise you will served cached webP versions of your HTML pages to non-webP supported web browsers
     
  12. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    I do not enable webp pages though.
     
  13. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Guess it can be removed if you don't serve webP image files. It's part of official cache enabler advanced configuration so has it's purpose otherwise.
     
  14. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    you can also benchmark the speed between removed code vs code intact too and see if there's a difference
     
  15. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    from official cache enabler page regarding webP code in nginx advanced config
    So technically if you do not serve webP files, there will be no webP cached HTML file so served from Nginx via normal cached HTML file. I'd expect if your case with versus without the webP html line, performance would be the same then as cached files are served via Nginx - as would same be for webP served files, just served via Nginx webP HTML generated cache file instead.
     
  16. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    One thing I'm sure and learned today is that.. :)

    If the header has "x-cache-handler", then it will slower and won't scale as it's served by Nginx+PHP-FPM.
    If the header has NO "x-cache-handler", then it will be Much Faster and will Scale as it's served by Nginx only.
     
  17. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Did your benchmark load tests confirm this or you assuming just behind PHP-FPM service stopped and still served from cache, that it's better ? See https://community.centminmod.com/threads/cache-enabler-plugin-best-config.19113/#post-81397 conflicting info but you're mixing cache logic versus cache creation.

    I am pretty sure x-cache-handler: wp load tests still only show majority of the load from Nginx and not PHP-FPM the last time I tested. Unless it has changed since.
     
    • Like Like x 1
  18. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Just did a fresh centmin.sh menu option 22 wordpress with cache enabler install on 123.09beta01 and x-cache-handler: wp does bypass PHP-FPM and stress test load is only on Nginx. However, seems I came across an interetsing bug on cache enabler plugin activation it should add
    Code (Text):
    define('WP_CACHE', true);

    to wp-config.php

    but it seems to not do that on initial install. Manually adding makes it work. If i deactivate cache enabler plugin from wp-admin, it does remove WP_CACHE true setting so it isn't a wp-config.php file permission issue. But re-activating cache enabler plugin, doesn't re-add WP_CACHE true setting in wp-config.php.

    Using PHP 7.4.2 so not sure if it's related
     
    Last edited: Feb 4, 2020
  19. rdan

    rdan Well-Known Member

    4,863
    1,160
    113
    May 25, 2014
    Ratings:
    +1,740
    Local Time:
    6:33 PM
    Mainline
    10.2
    Yeah I encounter that too on 1 site and I have to manually add that code.

    Ctrl+F5 will still always show that header to you?
     
  20. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    8:33 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yes within browser sessions dev network tab but not with SSH curl header checks