Discover Centmin Mod today
Register Now

Wordpress Cache-Enabler Plugin WP Super Cache, KeyCDN Cache Enabler, Redis Cache User Agent Bypass for Wordpress

Discussion in 'Blogs & CMS usage' started by eva2000, Dec 29, 2015.

  1. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    1:23 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    With WP Super Cache, KeyCDN Cache Enabler, and Redis Cache methods for Wordpress caching, some times you want specific requests to bypass the front end respective caches. With Centmin Mod Nginx it's easy to do via setting up an Nginx mapping for $http_user_agent to a $bypass_cache variable and populating the map with user agent fields you want to set to a value of 1 to bypass cache or 0 to hit caching layer.


    To do this, add to nginx.conf http{} context the below nginx mapping where setting user agent to 1 allows that user agent http requests to bypass the below 3 outlined caching mechanisms for Wordpress. Setting to 0 allows those user agent requests to hit the front end respective caching layers in Wordpress.

    The example below sets loader.io or blitz.io load testing services' http request user agent to a value of 1 to bypass the below respective Wordpress caching layers. Useful if you want to test before and after enabling caching for Wordpress :)
    Code (Text):
    map $http_user_agent $bypass_cache {
        default                 0;
        "~blitz.io"             1;
        "~loader.io"            1;
        "~Siege"                1;
        "~ApacheBench"          1;
        "~h2load"               1;
    }
    

    For Redis caching of Wordpress at Nginx level outlined at community.centminmod.com/posts/18828/, in /usr/local/nginx/conf/wpincludes/newdomain.com/rediscache_newdomain.com.conf include file add an extra entry to allow specific user agents to bypass Redis Caching if needed
    Code (Text):
        if ($bypass_cache = 1) {
            set $skip_cache 1;
        }
    

    For Wordpress Super Cache plugin for centmin.sh menu option 22 auto installed Wordpress outlined at centminmod.com/nginx-wordpress-installer.html, in /usr/local/nginx/conf/wpincludes/newdomain.com/wpsupercache_newdomain.com.conf include file add an extra entry to allow specific user agents to bypass WP Super Cache if needed
    Code (Text):
        if ($bypass_cache = 1) {
            set $cache_uri 'null cache';
        }
    

    For KeyCDN Cache Enabler plugin outlined at community.centminmod.com/threads/wp-cacher-enabler-plugin-by-keycdn-folks.5107/, in /usr/local/nginx/conf/wpincludes/newdomain.com/wpcacheenabler_domain1.com.conf include file add an extra entry to allow specific user agents to bypass Cache Enabler if needed
    Code (Text):
        if ($bypass_cache = 1) {
            set $cache_uri 'null cache';
        }
    
     
    Last edited: Mar 17, 2017
  2. bocuavung

    bocuavung New Member

    8
    1
    3
    Sep 18, 2019
    Mars
    Ratings:
    +1
    Local Time:
    10:23 AM
    1.17.3
    10.3.18
    How about rocket nginx cache?
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    1:23 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod doesn't install Rocket Cache Nginx configuration, so would be up to you or Rocket Cache folks to outline how to bypass cache for specific user agents.