Welcome to Centmin Mod Community
Become a Member

Wordpress Wordpress Redis Caching and nginx

Discussion in 'Blogs & CMS usage' started by tjk, Sep 22, 2016.

  1. tjk

    tjk Member

    76
    16
    8
    Jun 27, 2015
    Ratings:
    +27
    Local Time:
    7:41 AM
    Hey @eva2000, been playing with EasyEngine and VPSSIM, and both of them include built in configuration for Wordpress deployments using nginx redis for caching, including the parts necessary for nginx conf.


    I know you have a built in WP deployment function, but do you include the nginx/redis configuration if someone wants to use that for caching?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    9:41 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Support is there for redis nginx level caching for Wordpress but for Centmin Mod 123.08stable centmin.sh menu option 22 it's fully manual switch from WP Super Cache over process and only with Centmin Mod 123.09beta01's centmin.sh menu option 22 is it partially manual switch over from default Keycdn cache enabler as you install Redis as per Redis - How to install Redis server on Centmin Mod LEMP stack | Centmin Mod Community

    Then need to implement it as per Redis - How to install Redis server on Centmin Mod LEMP stack | Centmin Mod Community Centmin Mod 123.09beta01 unlike 123.08stable, when centmin.sh menu option 22 runs creates the include files only and has commented out entries in auto generated nginx vhost for php redis include files created which you need to manually uncomment and switch over.

    I am using redis nginx level caching on Wordpress7 demo site at http://wordpress7.centminmod.com/186/php-7-0-1-redis-caching-for-wordpress/ which was created via centmin.sh menu option 22 originally on WP Super Cache and manual switch to Redis Nginx level caching.

    @JarylW has found Centmin Mod 123.09beta01 centmin.sh menu option 22 default KeyCDN cache enabler installed caching as fast if not faster than Redis Nginx level caching, so leaving KeyCDN cache enabler as default is also an option you can choose.
     
  3. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    9:41 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  4. tjk

    tjk Member

    76
    16
    8
    Jun 27, 2015
    Ratings:
    +27
    Local Time:
    7:41 AM
    I haven't checked yet, but please make the flush cache time configurable with wpredis, if you can. Both EE and VPSSIM do not offer this, and they have a silly high ttl.
     
  5. tjk

    tjk Member

    76
    16
    8
    Jun 27, 2015
    Ratings:
    +27
    Local Time:
    7:41 AM
    Otherwise, things like Discourse for comments, wpforo, etc never get updated until the ttl expires. Poor coding for sure, I mentioned it over on EE and like most threads, they go ignored.
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    9:41 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    try this create a copy of /usr/local/nginx/conf/php-rediscache.conf i.e. /usr/local/nginx/conf/php-rediscache-shortttl.conf
    Code (Text):
    cp -a /usr/local/nginx/conf/php-rediscache.conf /usr/local/nginx/conf/php-rediscache-shortttl.conf

    edit the copy at /usr/local/nginx/conf/php-rediscache-shortttl.conf and

    change /redis-store location to /redis-store-shortttl
    Code (Text):
    srcache_store PUT /redis-store key=$escaped_key;
    

    to
    Code (Text):
    srcache_store PUT /redis-store-shortttl key=$escaped_key;
    

    in your /usr/local/nginx/conf/wpincludes/${vhostname}/rediscache_${vhostname}.conf where ${vhostname} is your domain.com, add a modified copy of /redis-store location after itself and change path as /redis-store-shortttl but change redis2_query expire value from 6 hours to 3600 seconds = 60 min = 1hr or whatever you want.
    Code (Text):
    location /redis-store {
      internal  ;
      set_unescape_uri $key $arg_key ;
      redis2_query set $key $echo_request_body;
      redis2_query expire $key 6h;
      redis2_pass  redisbackend;
      redis2_connect_timeout 60s;
      redis2_read_timeout 60s;
      redis2_send_timeout 60s;
    }
    
    location /redis-store-shortttl {
      internal  ;
      set_unescape_uri $key $arg_key ;
      redis2_query set $key $echo_request_body;
      redis2_query expire $key 3600;
      redis2_pass  redisbackend;
      redis2_connect_timeout 60s;
      redis2_read_timeout 60s;
      redis2_send_timeout 60s;
    }
    

    Then in nginx domain vhost files create specific location matches where you want to use shorter redis cache ttl of 3600 seconds i.e. /comments set the copied include file /usr/local/nginx/conf/php-rediscache-shortttl.conf
    Code (Text):
    location ~* /comments {
      include /usr/local/nginx/conf/php-rediscache-shortttl.conf;
    }
    

    or for wpforo /community
    Code (Text):
    location ~* /community {
      include /usr/local/nginx/conf/php-rediscache-shortttl.conf;
      try_files $uri $uri/ /index.php?$args;
    }
    

    You can extend that to several include files with various redis2_query expire ttl values and location paths.
     
    Last edited: Sep 24, 2016
  7. tjk

    tjk Member

    76
    16
    8
    Jun 27, 2015
    Ratings:
    +27
    Local Time:
    7:41 AM
    Way to complex, and to keep it updated, etc :)
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    9:41 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+