Discover Centmin Mod today
Register Now

The out of the box cache rules needs to be updated for WordPress running any ecommerce solution

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Saumya Majumder, Aug 18, 2016.

  1. JarylW

    JarylW Active Member

    216
    41
    28
    Jun 19, 2014
    Singapore
    Ratings:
    +103
    Local Time:
    2:53 PM
    Cache enabler by default already doesn't cache the cart checkout and account pages, even without the rules. Their nginx conf settings

    WordPress Cache Enabler Plugin - KeyCDN Support

    Code:
    server {
    
        set $cache_uri $request_uri;
    
        # 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 ~* "(/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") {
            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';
        }
    
        location / {
            gzip_static on; # this directive is not required but recommended
            try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
        }
    
        ...
    
    }


     
  2. eva2000

    eva2000 Administrator Staff Member

    58,907
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    4:53 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    i don't see anything in those rules that would exclude checkout/account pages though ? unless it's in the php code itself
     
  3. JarylW

    JarylW Active Member

    216
    41
    28
    Jun 19, 2014
    Singapore
    Ratings:
    +103
    Local Time:
    2:53 PM
    Yea. The plugin just doesnt create any cache for the woocommerce pages (maybe with exception of /shop/ page)
     
  4. eva2000

    eva2000 Administrator Staff Member

    58,907
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    4:53 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    well doesn't hurt to specifically add it to the default cache-enable nginx setup :)
     
  5. Saumya Majumder

    Saumya Majumder Member

    60
    3
    8
    Mar 16, 2016
    Ratings:
    +12
    Local Time:
    12:23 PM
    1.9.12
    10.0.24
    Hey @eva2000 I've found another issue with Redis at Nginx level caching. You see when we login to wp admin as a admin, there is an option to enable the header toolbar while viewing your pages.

    Now recently I've seen an wired issue, after I enable that toolbar it shows a blank space at top. instead of showing the toolbar.

    Is there any way to not show cached version of the site when admin is logged in? Not sure if it's possible.
     
  6. eva2000

    eva2000 Administrator Staff Member

    58,907
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    4:53 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    that's already the default as it works for me that way and never had any blank pages for header toolbar
     
  7. Saumya Majumder

    Saumya Majumder Member

    60
    3
    8
    Mar 16, 2016
    Ratings:
    +12
    Local Time:
    12:23 PM
    1.9.12
    10.0.24
    Yes I found the issue it wasn't redis, it was deregistering dashicons.
     
  8. eva2000

    eva2000 Administrator Staff Member

    58,907
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    4:53 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Good to know :)