Get the most out of your Centmin Mod LEMP stack
Become a Member

Redis Redis clear cache ?

Discussion in 'Other Centmin Mod Installed software' started by Kuro, Apr 5, 2019.

  1. Kuro

    Kuro Member

    78
    8
    8
    Feb 8, 2018
    Ratings:
    +15
    Local Time:
    4:28 AM
    1.15.10
    10.3
    I am using redis (option 22) for my Wordpress site. I wonder how to automatically clear the cache by a given time period. (For example, I want my views every four hours to be updated once.)
     
  2. eva2000

    eva2000 Administrator Staff Member

    42,079
    9,499
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,615
    Local Time:
    7:28 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    you can setup redis-cli flushall via a cronjob though redis cache is set to 6hr TTL for centmin.sh menu option 22 installs in /usr/local/nginx/conf/wpincludes/${vhostname}/rediscache_${vhostname}.conf where ${vhostname} is your domain
    Code (Text):
    redis2_query expire $key 6h;

    and
    Code (Text):
    redis2_query expire $key 3600;
     
    • Like Like x 1
  3. Kuro

    Kuro Member

    78
    8
    8
    Feb 8, 2018
    Ratings:
    +15
    Local Time:
    4:28 AM
    1.15.10
    10.3
    I see the "wp_is_mobile ()" function wordpress does not work with redis. For example, just delete the cache, which device first accessed (PC, Mobile) it will save html that device and distribute it to all remaining users. (For example, computer ads will be displayed on mobile devices.)
    #My default
    Code:
    # Block nginx-help log from public viewing
    location ~* /wp-content/uploads/nginx-helper/ { deny all; }
    
    set $skip_cache 0;
    
    # exclude mobile devices from redis caching
    #if ($redis_device = mobile) { set $skip_cache 1; }
    
    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
      set $skip_cache 1;
    }
    
    if ($query_string != "") {
      set $skip_cache 1;
    }
    
    # Don't cache uris containing the following segments
    if ($request_uri ~* "\?add-to-cart=|/cart/|/my-account/|/checkout/|/shop/checkout/|/store/checkout/|/customer-dashboard/|/addons/|/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
      set $skip_cache 1;
    }
    
    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|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 $skip_cache 1;
    }
    
    # bypass cache for woocommerce
    if ($arg_add-to-cart != "") {
      set $skip_cache 1;
    }
    
    ## bypass cache for empty woocommerce carts
    #if ($cookie_woocommerce_items_in_cart != "0") {
    #  set $skip_cache 1;
    #}
    
    location /redis-fetch {
      internal  ;
      set  $redis_key $args;
      redis_pass  redisbackend;
      redis_connect_timeout 60000;
      redis_read_timeout 60000;
      redis_send_timeout 60000;
    }
    
    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;
    }
    
     
    Last edited: Apr 5, 2019
  4. Jon Snow

    Jon Snow Active Member

    448
    66
    28
    Jun 30, 2017
    Ratings:
    +104
    Local Time:
    5:28 PM
    Nginx 1.13.9
    MariaDB 10.1.31
    @eva2000 What's the manual way to clear redis cache if I set it up using the XF 2 redis guide?
     
  5. pamamolf

    pamamolf Premium Member Premium Member

    3,530
    342
    83
    May 31, 2014
    Ratings:
    +656
    Local Time:
    11:28 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    Code:
    redis-cli FLUSHALL
     
    • Like Like x 2
    • Agree Agree x 1