Welcome to Centmin Mod Community
Register Now

Wordpress Cache-Enabler Plugin Caching search results with standard centminmod install ?

Discussion in 'Blogs & CMS usage' started by julliuz, Jul 16, 2020.

  1. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    Does anyone know if I can enable search query caching with cache enabler ?
    Maybe within the cacheenabler wpincludes config file somehow ?
    Any other method ? (I know wp rocket does it but I don't want to change to that one if possible)


    Thank you!
    (queries are made the standard way: /?s="searchterm"
     
  2. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
  3. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    I found out how to change ?s= to /search/*keyword , now cache enabler started making cached files (after removing the cache exception for searches in the php file) of the results but it isn’t showing them still because the initiator is still ?s=* and thats a query so the query gets processed instead of the /search/page served. Any help would be much appreciated. Maybe nginx can be forced to serve search results that are already in the cache folder somehow ?
     
  4. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    I believe you need to modify wordpress code itself.

    Also your cache enabler include file at /usr/local/nginx/conf/wpincludes/cache-enabler.domain.com/wpcacheenabler_cache-enabler.domain.com.conf where domain of wordpress site = cache-enabler.domain.com is generated by centmin.sh menu option 22 in your nginx vhost has a general general to ignore/bypass cache for all query strings
    Code (Text):
        if ($query_string != "") {
            set $cache_uri 'nullcache';
        }
    

    but that might not be where you issues lie as wordpress code itself needs modifying or if you can find a wordpress plugin that converts ?s= to /search/
     
  5. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    ?s= is already converted by this function:

    function wpb_change_search_url() {
    if ( is_search() && ! empty( $_GET['s'] ) ) {
    wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
    exit();
    }
    }
    add_action( 'template_redirect', 'wpb_change_search_url' );

    that's why cache enabler started caching the pages people land on but the initial searches aren't being served as /search/ in chrome dev tools you can see that it still gets initiated by ?s and then people go to /search/ thus the cached version doesn't get served. :(
     
  6. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    cache enabler include file at /usr/local/nginx/conf/wpincludes/cache-enabler.domain.com/wpcacheenabler_cache-enabler.domain.com.conf where domain of wordpress site = cache-enabler.domain.com is generated by centmin.sh menu option 22 in your nginx vhost contains the $cache_enabler_uri variable used to determine if a request url is in cache or not
    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';
        }
    

    and centmin.sh menu option 22 generated nginx vhost has try_files match which looks to see if the is a cache entry to serve and it looks first in $cache_enabler_uri variable
    Code (Text):
      # for wp cache enabler plugin
      try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args; 
    

    so if i visited wordpress index page + searched for terms world and wordpress cache, cache enabler with modification to remove is_search cache exclusion would populate with cache items as follows
    Code (Text):
    ls -lahR /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/
    /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/:
    total 44K
    drwxrws--- 3 nginx nginx 4.0K Jul 16 13:48 .
    drwxrws--- 3 nginx nginx 4.0K Jul 16 13:36 ..
    -rw-rw---- 1 nginx nginx  24K Jul 16 13:48 index.html
    -rw-rw---- 1 nginx nginx 6.6K Jul 16 13:48 index.html.gz
    drwxrws--- 4 nginx nginx 4.0K Jul 16 13:43 search
    
    /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/search:
    total 16K
    drwxrws--- 4 nginx nginx 4.0K Jul 16 13:43 .
    drwxrws--- 3 nginx nginx 4.0K Jul 16 13:48 ..
    drwxrws--- 2 nginx nginx 4.0K Jul 16 13:43 wordpress+cache
    drwxrws--- 2 nginx nginx 4.0K Jul 16 13:36 world
    
    /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/search/wordpress+cache:
    total 44K
    drwxrws--- 2 nginx nginx 4.0K Jul 16 13:43 .
    drwxrws--- 4 nginx nginx 4.0K Jul 16 13:43 ..
    -rw-rw---- 1 nginx nginx  25K Jul 16 13:43 index.html
    -rw-rw---- 1 nginx nginx 6.9K Jul 16 13:43 index.html.gz
    
    /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/search/world:
    total 40K
    drwxrws--- 2 nginx nginx 4.0K Jul 16 13:36 .
    drwxrws--- 4 nginx nginx 4.0K Jul 16 13:43 ..
    -rw-rw---- 1 nginx nginx  24K Jul 16 13:36 index.html
    -rw-rw---- 1 nginx nginx 6.7K Jul 16 13:36 index.html.gz
    

    you see the the $cache_enabler_uri varaible defined parameters aren't able to match for /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/cache-enabler.domain.com/search/world/index.html or gzip version
     
  7. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    I added Check-Uri header to ?s= query arguments to display and check what $cache_uri nginx sees when you modified wordpress to redirect to /search

    Code (Text):
        if ($arg_s) {
          set $cache_uri $request_uri;
          set $check_surl $cache_uri;
        }
        add_header Check-Uri "$check_surl";
    
        # default html file
        set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';
    

    Code (Text):
    curl -IL http://cache-enabler.domain.com/?s=wordpress+cache
    HTTP/1.1 302 Found
    Date: Thu, 16 Jul 2020 14:04:39 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    X-Redirect-By: WordPress
    Location: http://cache-enabler.domain.com/search/wordpress+cache
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Check-Uri: /?s=wordpress+cache
    
    HTTP/1.1 200 OK
    Date: Thu, 16 Jul 2020 14:04:39 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    Link: <http://cache-enabler.domain.com/wp-json/>; rel="https://api.w.org/"
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    

    Nginx sees $cache_uri as = Check-Uri value of = /?s=wordpress+cache while nginx $cache_uri is look for /search/wordpress+cache to determine if cache entry exists

    so won't match in try_files for cache lookup variable $cache_enabler_uri
    Code (Text):
      # for wp cache enabler plugin
      try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    

    and subsequent /search/wordpress+cache requests won't match in try_files $cache_enabler_uri either

    edit: did get a bit further in reassigning $cache_uri with /search/wordpres+cache by changing includes to
    Code (Text):
        if ($args ~* s=(.*)) {
          set $cache_uri $request_uri;
          set $check_surl $cache_uri;
          set $cache_uri /search/$1;
        }
        add_header Check-Uri "$check_surl";
        add_header Set-Uri "$cache_uri";
    
        # default html file
        set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';
    

    So now returned header via Set-Uri is = $cache_uri
    Code (Text):
    curl -IL http://cache-enabler.domain.com/?s=wordpress+cache                                                        
    HTTP/1.1 302 Found
    Date: Thu, 16 Jul 2020 14:39:03 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    X-Redirect-By: WordPress
    Location: http://cache-enabler.domain.com/search/wordpress+cache
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Check-Uri: /?s=wordpress+cache
    Set-Uri: /search/wordpress+cache
    
    HTTP/1.1 200 OK
    Date: Thu, 16 Jul 2020 14:39:03 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    Link: <http://cache-enabler.domain.com/wp-json/>; rel="https://api.w.org/"
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Set-Uri: /search/wordpress+cache

    Code (Text):
    curl -I http://cache-enabler.domain.com/search/wordpress+cache         
    HTTP/1.1 200 OK
    Date: Thu, 16 Jul 2020 14:56:12 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    Link: <http://cache-enabler.domain.com/wp-json/>; rel="https://api.w.org/"
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Set-Uri: /search/wordpress+cache
    
     
    Last edited: Jul 17, 2020
  8. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    damn :( I really wish I could stay with cache enabler, guess not.
     
  9. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    If you have Cloudflare in front, just setup page rule to cache everything with edge ttl cache timeout for url path /search/* or something :)

    wp-search-pretty-url-cacheverything-01.png
     
    Last edited: Jul 17, 2020
  10. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    This might be a weird request but how would you do a nginx rewrite to change:
    /?s=*keyword+keyword* to /search/*keyword+keyword* ?

    When I browse to domain.com/search/keyword , it serves the cached files also it makes the file when it doesn't exist yet. So I think that by rewriting it from the get go might do the trick ?
    Already have this in place to add a trailing slash (otherwise it didn't recognize it, with a trailing slash it does!)
    rewrite ^([^.]*[^/])$ $1/ permanent;
     
  11. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    might have worked it out after removing is_search exclusion from cache_enabler.class.php
    Code (Text):
    diff -u cache_enabler.class.php-orig cache_enabler.class.php-removesearch
    --- cache_enabler.class.php-orig        2020-07-17 05:33:33.933006105 +0000
    +++ cache_enabler.class.php-removesearch        2020-07-17 05:34:17.572342714 +0000
    @@ -1407,7 +1407,7 @@
             }
     
             // conditional tags
    -        if ( self::_is_index() OR is_search() OR is_404() OR is_feed() OR is_trackback() OR is_robots() OR is_preview() OR post_password_required() ) {
    +        if ( self::_is_index() OR is_404() OR is_feed() OR is_trackback() OR is_robots() OR is_preview() OR post_password_required() ) {
                 return true;
             }
    

    you would change Wordpress functions.php slightly so redirect has an ending forward slash / - updated, I created a Wordpress Pretty Search Url plugin which can do this functions.php change so you don't need to modify functions.php.
    PHP:
    function wpb_change_search_url() {
      if ( 
    is_search() && ! empty( $_GET['s'] ) ) {
        
    wp_redirecthome_url"/search/" ) . urlencodeget_query_var's' ) ) . "/");
        exit();
      }
    }
    add_action'template_redirect''wpb_change_search_url' );
    then in /usr/local/nginx/conf/wpincludes/cache-enabler.domain.com/wpcacheenabler_cache-enabler.domain.com.conf where domain of wordpress site = cache-enabler.domain.com is generated by centmin.sh menu option 22, reassigning $cache_uri with /search/wordpres+cache by changing parts of includes above the initial set $cache_enabler_uri to

    July 20, 2020: made some changes in /usr/local/nginx/conf/wpincludes/cache-enabler.domain.com/wpcacheenabler_cache-enabler.domain.com.conf

    from
    Code (Text):
       if ($args ~* s=(.*)) {
         set $cache_uri $request_uri;
         set $check_surl $cache_uri;
         set $cache_uri /search/$1;
       }
       add_header Check-Uri "$check_surl";
       add_header Set-Uri "$cache_uri";
    
       # 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_webp '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index-webp.html';
       }
    

    to the below version so Nginx takes over from Wordpress redirects so PHP-FPM request is totally bypassed for query string ?s= requests and specific /search/ location match so that you can do more specific things in future i.e. rate limit within /search/ if needed
    Code (Text):
       if ($args ~* s=(.*)) {
         set $cache_uri $request_uri;
         set $check_surl $cache_uri;
         set $cache_uri /search/$1/;
         set $cache_uri_search /search/$1/;
         set $cache_enabler_uri_search '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri_search}index.html';
       }
       location ~ /search/(.*) {
         set $cache_uri $request_uri;
         set $check_surl $cache_uri;
         set $cache_uri_search $request_uri;
         set $cache_enabler_uri_search '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${check_surl}index.html';
         try_files $cache_enabler_uri_search $cache_enabler_uri_webp $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
       }
       add_header Check-Uri "$check_surl";
       add_header Set-Uri "$cache_uri";
    
       # 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_webp '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index-webp.html';
       }
    
       if (-f $document_root$cache_enabler_uri_search) {
         set $search_exists $cache_enabler_uri_search;
         return 302 https://$host$cache_uri_search;
       }
       if (!-f $document_root$cache_enabler_uri_search) {
         set $search_exists $cache_enabler_uri_search;
       }
       #add_header Check-File "$search_exists";
    

    The results for July 20, 2020 updated config for cached search requests benchmarks with my forked wrk, wrk-cmm tool now look like
    Code (Text):
    wrk-cmm -t4 -c50 -d20s --latency --breakout http://cache-enabler.domain.com/search/worldpress+cache/
    Running 20s test @ http://cache-enabler.domain.com/search/worldpress+cache/
      4 threads and 50 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency     2.25ms   15.86ms 301.40ms   98.66%
        Connect   203.46us  148.93us 660.00us   87.50%
        TTFB        2.24ms   15.87ms 301.39ms   98.66%
        TTLB       10.40us   37.28us   9.02ms   99.96%
        Req/Sec    28.00k     9.43k   44.87k    66.67%
      Latency Distribution
         50%  311.00us
         75%  534.00us
         90%    1.61ms
         99%   49.76ms
      2226160 requests in 20.07s, 41.85GB read
    Requests/sec: 110910.78
    Transfer/sec:      2.08GB
    

    Code (Text):
    wrk-cmm -t4 -c50 -d20s --latency --breakout http://cache-enabler.domain.com/?s=wordpress+cache
    Running 20s test @ http://cache-enabler.domain.com/?s=wordpress+cache
      4 threads and 50 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency   775.44us    1.85ms  29.36ms   91.06%
        Connect   237.04us  131.89us 567.00us   62.75%
        TTFB      771.92us    1.85ms  29.36ms   91.06%
        TTLB        2.09us   32.86us  10.16ms   99.98%
        Req/Sec    50.01k    12.86k   71.21k    68.12%
      Latency Distribution
         50%  151.00us
         75%  308.00us
         90%    2.14ms
         99%    9.24ms
      3985306 requests in 20.08s, 2.36GB read
    Requests/sec: 198476.64
    Transfer/sec:    120.38MB
    


    So now returned header via Set-Uri is = $cache_uri
    Code (Text):
    curl -IL http://cache-enabler.domain.com/?s=wordpress+cache
    HTTP/1.1 200 OK
    Date: Thu, 16 Jul 2020 15:07:02 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 25301
    Last-Modified: Thu, 16 Jul 2020 14:41:58 GMT
    Connection: keep-alive
    Vary: Accept-Encoding
    ETag: "5f106736-62d5"
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Check-Uri: /?s=wordpress+cache
    Set-Uri: /search/wordpress+cache/
    Accept-Ranges: bytes
    

    direct cached url access
    Code (Text):
    curl -I http://cache-enabler.domain.com/search/worldpress+cache/
    HTTP/1.1 200 OK
    Date: Thu, 16 Jul 2020 15:08:23 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 19736
    Last-Modified: Thu, 16 Jul 2020 15:07:54 GMT
    Connection: keep-alive
    Vary: Accept-Encoding
    ETag: "5f106d4a-4d18"
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Set-Uri: /search/worldpress+cache/
    Accept-Ranges: bytes
    

    diff compare of embedded html tag from cache enabler
    Code (Text):
    diff -u <(curl -sL http://cache-enabler.domain.com/?s=wordpress+cache) <(curl -s http://cache-enabler.domain.com/search/worldpress+cache/) | tail -5
    
    -<!-- Cache Enabler by KeyCDN @ 16.07.2020 14:41:58 (html) -->
    \ No newline at end of file
    +<!-- Cache Enabler by KeyCDN @ 16.07.2020 15:07:54 (html) -->
    \ No newline at end of file
    

    Old pre-July 20, 2020 load test with my forked wrk, wrk-cmm with wordpress search cached
    Code (Text):
    wrk-cmm -t4 -c50 -d20s --latency --breakout http://cache-enabler.domain.com/search/worldpress+cache/
    Running 20s test @ http://cache-enabler.domain.com/search/worldpress+cache/
      4 threads and 50 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency     1.01ms    4.16ms  99.65ms   97.01%
        Connect   159.21us   71.17us 288.00us   58.33%
        TTFB        1.00ms    4.16ms  99.64ms   97.01%
        TTLB       10.21us   32.01us  11.02ms   99.97%
        Req/Sec    23.94k     9.82k   45.89k    64.12%
      Latency Distribution
         50%  415.00us
         75%  603.00us
         90%    1.19ms
         99%   10.78ms
      1907359 requests in 20.04s, 35.79GB read
    Requests/sec:  95189.83
    Transfer/sec:      1.79GB
    

    Old pre-July 20, 2020 direct query search cached
    Code (Text):
    wrk-cmm -t4 -c50 -d20s --latency --breakout http://cache-enabler.domain.com/?s=wordpress+cache     
    Running 20s test @ http://cache-enabler.domain.com/?s=wordpress+cache
      4 threads and 50 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency   738.15us    2.44ms 108.60ms   95.81%
        Connect   144.73us   69.16us 280.00us   60.42%
        TTFB      724.86us    2.44ms 108.58ms   95.81%
        TTLB       13.46us   58.63us  14.02ms   99.96%
        Req/Sec    26.26k     6.27k   39.64k    70.00%
      Latency Distribution
         50%  351.00us
         75%  546.00us
         90%    1.21ms
         99%    7.54ms
      2092164 requests in 20.03s, 50.16GB read
    Requests/sec: 104448.19
    Transfer/sec:      2.50GB

    compared to default without wordpress search cache
    Code (Text):
    curl -IL http://cache-enabler.domain.com/?s=wordpress+cache                                                                        
    HTTP/1.1 200 OK
    Date: Thu, 16 Jul 2020 15:46:04 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    Link: <http://cache-enabler.domain.com/wp-json/>; rel="https://api.w.org/"
    Server: nginx centminmod
    X-Powered-By: centminmod
    X-Xss-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    Check-Uri: /?s=wordpress+cache
    Set-Uri: /?s=wordpress+cache
    

    cached search at 95,189 OR 104,448 requests/sec versus non-cached search at 332 requests/sec
    Code (Text):
    wrk-cmm -t4 -c50 -d20s --latency --breakout http://cache-enabler.domain.com/?s=wordpress+cache    
    Running 20s test @ http://cache-enabler.domain.com/?s=wordpress+cache
      4 threads and 50 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency   143.66ms   16.60ms 238.90ms   68.44%
        Connect   165.79us   83.37us 334.00us   56.25%
        TTFB      143.60ms   16.60ms 238.79ms   68.47%
        TTLB       63.16us   25.84us   1.19ms   85.77%
        Req/Sec    83.38     14.48   121.00     68.62%
      Latency Distribution
         50%  144.40ms
         75%  154.74ms
         90%  163.80ms
         99%  185.14ms
      6663 requests in 20.02s, 181.04MB read
    Requests/sec:    332.85
    Transfer/sec:      9.04MB
    

    posted an issue/request at Make is_search() cache exclusion an admin option · Issue #83 · keycdn/cache-enabler for at least making cache enabler support admin option to disable/enable search cache support

    Search Cache Invalidation Cronjob



    Centmin Mod 123.09beta01's centmin.sh menu option 22 wordpress auto installer with Cache Enabler caching selected will also generate an optional cronjob to invalidate and remove Cache Enabler cached files from cache and look similar to:

    Remove Cache Enabler's cached files every day at 11:16pm (every 24hrs).
    Code (Text):
    16 23 * * * echo "cache-enabler.domain.com cacheenabler cron"; sleep 174s ; rm -rf /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/* > /dev/null 2>&1
    

    With above /search/ caching modifications, you could setup a separate /search/ cache invalidation cronjob which can have a shorter or longer interval than default Cache Enabler cache time.

    For example delete /search/ cached files every 5 minutes
    Code (Text):
    */5 * * * * echo "cache-enabler.domain.com cacheenabler search cron"; sleep 14s ; rm -rf /home/nginx/domains/cache-enabler.domain.com/public/wp-content/cache/cache-enabler/search/* > /dev/null 2>&1
    
     
    Last edited: Jul 22, 2020
  12. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    seems to have done the trick ! amazing , thanks a lot man !
     
  13. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    Yeah interesting problem to solve for. Might want to write a wordpress plugin for the functions.php changes so you don't need to edit functions.php directly.

    @jcat and @rdan might like this too :)
     
    Last edited: Jul 17, 2020
  14. tininho

    tininho Active Member

    182
    44
    28
    May 22, 2019
    eu
    Ratings:
    +135
    Local Time:
    11:04 AM
    I use this one: https://wordpress.org/plugins/code-snippets/
     
  15. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    wow very handy :D
     
  16. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
  17. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    Is it just my idea or does that php function only rename/redirect after the call to the database as it still has to call to php to actually rename the thing? Would a nginx rewrite maybe be better ? before it ever hit anything and when it sees the full url it just serves that one ?

    maybe I'm completely off haha
     
  18. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    would only call php if you didn't have cache enabler advance caching at nginx level setup as I outlined above

    with cache enabler cached search
    Code (Text):
    wrk-cmm -t4 -c50 -d20s --latency --breakout http://cache-enabler.domain.com/?s=wordpress+cache            
    Running 20s test @ http://cache-enabler.domain.com/?s=wordpress+cache
      4 threads and 50 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency   738.15us    2.44ms 108.60ms   95.81%
       Connect   144.73us   69.16us 280.00us   60.42%
       TTFB      724.86us    2.44ms 108.58ms   95.81%
       TTLB       13.46us   58.63us  14.02ms   99.96%
       Req/Sec    26.26k     6.27k   39.64k    70.00%
      Latency Distribution
        50%  351.00us
        75%  546.00us
        90%    1.21ms
        99%    7.54ms
      2092164 requests in 20.03s, 50.16GB read
    Requests/sec: 104448.19
    Transfer/sec:      2.50GB
    
     
  19. julliuz

    julliuz Member

    39
    3
    8
    Dec 20, 2018
    Ratings:
    +7
    Local Time:
    10:04 AM
    1.15
    Hmm interesting, I installed this setup a year ago or so. Did anything ever change in the config files since then ? Is there a place where I can see a freshly setup'd cache enabler option 22 configs by any chance ?
     
  20. eva2000

    eva2000 Administrator Staff Member

    50,460
    11,661
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,082
    Local Time:
    6:04 PM
    Nginx 1.25.x
    MariaDB 10.x
    easiest way is on a test server or local virtualbox centmin mod, run centmin.sh menu option 22 to create a test wordpress cache enabler site and then inspect and copy over the latest configs to your live instance :)