Discover Centmin Mod today
Register Now

Wordpress Change from Cache Enabler to Fastcgi_cache

Discussion in 'Blogs & CMS usage' started by fabianski, Jun 11, 2019.

Tags:
  1. fabianski

    fabianski Member

    102
    13
    18
    Feb 20, 2019
    Brazil
    Ratings:
    +35
    Local Time:
    9:46 PM
    Is there any way to do this?
    Thanks in advance!
     
  2. eva2000

    eva2000 Administrator Staff Member

    41,384
    9,295
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,259
    Local Time:
    10:46 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Yes it's possible - just not in automated way as you'd have to manually do that yourself and fastcgi_cache right now isn't supported official in centmin mod by me - you can do it yourself but issues would be up to you to resolve yourself.

    I'd only support the 3 offered full page caches installed via centmin.sh menu option 22.

    centmin.sh menu option 22, keycdn cache enabler is still the best recommended version for least problems while giving the best performance of it's kind - it's better version of wp super cache.
     
  3. fabianski

    fabianski Member

    102
    13
    18
    Feb 20, 2019
    Brazil
    Ratings:
    +35
    Local Time:
    9:46 PM
    my theme has many compatibility problems with the enabler cache, I have tried to fix but without success.
    It is actually a good plugin for caching, because when I tried to use wordpress super caching at times with many hits it does not support the load well and shows its limitations.

    Before migrating to cmm I used the fastcgi cache and it worked as expected.
    Anyway, thanks for the help!
     
  4. eva2000

    eva2000 Administrator Staff Member

    41,384
    9,295
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,259
    Local Time:
    10:46 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    what theme are you using ? what specific issues ?

    maybe you should list and document the theme issues with keycdn cache enabler and share them with keycdn folks at [Cache Enabler - WordPress Cache] Support | WordPress.org

    example at WordPress Cache Enabler Plugin - KeyCDN Support
     
    • Like Like x 1
  5. fabianski

    fabianski Member

    102
    13
    18
    Feb 20, 2019
    Brazil
    Ratings:
    +35
    Local Time:
    9:46 PM
    two things

    1. Even the cache for smartphones being ignored the plugin caches the page if it is visited on a mobile phone, for example. So if someone accesses the same address on the computer she will see the mobile version.
    I can circumvent it warm up the cache regularly, this does solve, but it's something I want to fix

    2. Sometimes logged in users are served with cache. This is the main problem, mainly because few times I have been able to test it myself, but I have already received several emails from my users reporting this problem.

    I'll search better and create a topic in the forum support forum.
     
  6. eva2000

    eva2000 Administrator Staff Member

    41,384
    9,295
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,259
    Local Time:
    10:46 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    is your theme serving it's own separate version of theme for mobile vs desktop users ? i.e. via a mobile plugin ?
     
  7. eva2000

    eva2000 Administrator Staff Member

    41,384
    9,295
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,259
    Local Time:
    10:46 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    what's contents of your /usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf look like ? where ${vhostname} = your domain name

    you can post output for cat command which outputs contents of your include file for /usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf in CODE bbcode tags

    change vhostname variable form yourdomain.com to your wordpress domain
    Code (Text):
    vhostname=yourdomain.com
    cat /usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf
    

    there should be a line in the file for excluding mobile devices from cache if you opted to exclude during centmin.sh menu option 22 wordpress install/setup
    Code (Text):
    if ($cmwpcache_device = mobile) { set $cache_uri 'nullcache'; }

    it should NOT have a hash # in front which disables the mobile device cache exclusion. If you answered yes to cache mobile devices, then it would have hash # in front of that line.

    $cmwpcache_device variable checks and references nginx map setup in include file /usr/local/nginx/conf/wpcacheenabler_map.conf added in nginx.conf
    Code (Text):
    map $http_user_agent $cmwpcache_device {
        default                                     'desktop';
        ~*(iPad|iPhone|Android|IEMobile|Blackberry) 'mobile';
        "~*Firefox.*Mobile"                         'mobile';
        "~*ipod.*mobile"                            'mobile';
        "~*Opera\ Mini"                             'mobile';
        "~*Opera\ Mobile"                           'mobile';
        "~*Mobile"                                  'mobile';
        "~*Tablet"                                  'mobile';
        "~*Kindle"                                  'mobile';
        "~*Windows\ Phone"                          'mobile';
    }
    

    could be your visitors' mobile devices useragent isn't matching one of these ?
     
  8. fabianski

    fabianski Member

    102
    13
    18
    Feb 20, 2019
    Brazil
    Ratings:
    +35
    Local Time:
    9:46 PM
    here my configs

    i did very small changes

    Code:
        # Block nginx-help log from public viewing
        location ~* /wp-content/uploads/nginx-helper/ { deny all; }
    
        set $cache_uri $request_uri;
    
        # exclude mobile devices from redis caching
        if ($cmwpcache_device = mobile) { set $cache_uri 'nullcache'; }
    
        # bypass cache if POST requests or URLs with a query string
        if ($request_method = POST) {
            set $cache_uri 'nullcache';
        }
        if ($query_string != "") {
            set $cache_uri 'nullcache';
        }
    
        # bypass cache if URLs containing the following strings
        if ($request_uri ~* "(\?add-to-cart=|/cart/|/my-account/|/checkout/|/shop/checkout/|/store/checkout/|/customer-dashboard/|/addons/|/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
            set $cache_uri 'nullcache';
        }
    
        # bypass cache if the cookies containing the following strings
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in|edd_items_in_cart|woocommerce_items_in_cart|woocommerce_cart_hash|woocommerce_recently_viewed|wc_session_cookie_HASH|wp_woocommerce_session_|wptouch_switch_toggle") {
            set $cache_uri 'nullcache';
        }
    
        # bypass cache for woocommerce
        if ($arg_add-to-cart != "") {
            set $cache_uri 'nullcache';
        }
    
        ## bypass cache for empty woocommerce carts
        #if ($cookie_woocommerce_items_in_cart != "0") {
        #  set $cache_uri 'nullcache';
        #}
    
        # custom sub directory e.g. /blog
        set $custom_subdir '';
    
        # 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';
        }
    

    Code:
    #x# HTTPS-DEFAULT
     server {
     
       server_name domain.org www.domain.org;
       return 302 https://domain.org$request_uri;
       include /usr/local/nginx/conf/staticfiles.conf;
     }
    
    server {
      listen 443 ssl http2 reuseport;
      server_name domain.org;
    
      include /usr/local/nginx/conf/ssl/domain.org/domain.org.crt.key.conf;
      include /usr/local/nginx/conf/ssl_include.conf;
    
      # cloudflare authenticated origin pull cert community.centminmod.com/threads/13847/
      #ssl_client_certificate /usr/local/nginx/conf/ssl/cloudflare/domain.org/origin.crt;
      #ssl_verify_client on;
      http2_max_field_size 16k;
      http2_max_header_size 32k;
      # mozilla recommended
      ssl_ciphers TLS13-AES-128-GCM-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
      ssl_prefer_server_ciphers   on;
      #add_header Alternate-Protocol  443:npn-spdy/3;
    
      # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts
      add_header Strict-Transport-Security "max-age=31536000;";
      add_header X-Frame-Options SAMEORIGIN;
      add_header X-Xss-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;
      add_header Referrer-Policy "strict-origin-when-cross-origin";
      #spdy_headers_comp 5;
      ssl_buffer_size 1369;
      ssl_session_tickets on;
     
      # enable ocsp stapling
      resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 valid=10m;
      resolver_timeout 10s;
      ssl_stapling on;
      ssl_stapling_verify on;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/domain.org/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/domain.org/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/domain.org/autoprotect-domain.org.conf;
      root /home/nginx/domains/domain.org/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
     
      #WP ROCKET
      #include /usr/local/nginx/rocket-nginx/default.conf;
     
      include /usr/local/nginx/conf/wpincludes/domain.org/wpcacheenabler_domain.org.conf;
      #include /usr/local/nginx/conf/wpincludes/domain.org/wpsupercache_domain.org.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/domain.org/rediscache_domain.org.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
     
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    
      }
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
        #auth_basic "Private";
        #auth_basic_user_file /home/nginx/domains/domain.org/htpasswd_wplogin; 
        include /usr/local/nginx/conf/php.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-scripts\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-styles\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
      include /usr/local/nginx/conf/wpincludes/domain.org/wpsecure_domain.org.conf;
      include /usr/local/nginx/conf/php.conf;
     
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
      include /usr/local/nginx/conf/pre-staticfiles-local-domain.org.conf;
      include /usr/local/nginx/conf/pre-staticfiles-global.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
     
    }
    
    #redirecionar acesso direto por ip
      server {
            listen 80;
            server_name 123.123.123.123;
            return 301 https://domain.org;
    }

    Code:
    map $http_user_agent $cmwpcache_device {
        default                                     'desktop';
        ~*(iPad|iPhone|Android|IEMobile|Blackberry) 'mobile';
        "~*Firefox.*Mobile"                         'mobile';
        "~*ipod.*mobile"                            'mobile';
        "~*Opera\ Mini"                             'mobile';
        "~*Opera\ Mobile"                           'mobile';
        "~*Mobile"                                  'mobile';
        "~*Tablet"                                  'mobile';
        "~*Kindle"                                  'mobile';
        "~*Windows\ Phone"                          'mobile';
    }
    
     
  9. fabianski

    fabianski Member

    102
    13
    18
    Feb 20, 2019
    Brazil
    Ratings:
    +35
    Local Time:
    9:46 PM
    and a video showing what happens: