Want more timely Centmin Mod News Updates?
Become a Member

Homepage Cache Keeps Rebuilding

Discussion in 'Blogs & CMS usage' started by wlin, Apr 10, 2016.

  1. wlin

    wlin New Member

    9
    1
    3
    Apr 10, 2016
    Ratings:
    +1
    Local Time:
    6:12 AM
    Hi, noticed the homepage keeps rebuilding the cache on each page load. I've set cache timeout and garbage collection, unchecked cache from clearing on page changes, unchecked homepage checking. I've also removed $args from the location block in the server config. The other pages will cache and expire accordingly as I've set it up. Just not the homepage. Also noticed if I add a trailing period or variable to the homepage URL, the cache also functions properly for that URL. Any ideas?
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,955
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,416
    Local Time:
    12:12 AM
    Nginx 1.13.x
    MariaDB 5.5
    Did you setup a wordpress permalinks format ? what format did you use ? how was wordpress installed ? manually or via centmin.sh menu option 22 auto installer Wordpress Nginx Auto Installer (WP Super Cache) ?

    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)
     
  3. wlin

    wlin New Member

    9
    1
    3
    Apr 10, 2016
    Ratings:
    +1
    Local Time:
    6:12 AM
    The permalink format is currently '/%postname%/%post_id%' and WP was installed manually. Here's the format of my nginx CONF

    Code:
    server {
        server_name website.com www.website.com;
        return 302 https://$server_name$request_uri;
    }
    server {
      listen 443 ssl http2;
      server_name website.com www.website.com;
      ssl_dhparam /usr/local/nginx/conf/ssl/website.com/dhparam.pem;
      ssl_certificate      /usr/local/nginx/conf/ssl/website.com/ssl-unified.crt;
      ssl_certificate_key  /usr/local/nginx/conf/ssl/website.com/website.com.key;
      ssl_prefer_server_ciphers on;
      ssl_buffer_size 1400;
      ssl_session_tickets on;
      include /usr/local/nginx/conf/ssl_include.conf;
      root /home/nginx/domains/website.com/public;
      location / {
      try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
      }
      location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
      rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
      rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
      rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
      rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
      }
      include /usr/local/nginx/conf/wpsecure.conf;
      include /usr/local/nginx/conf/wpsupercache.conf;
      include /usr/local/nginx/conf/php-wpsc.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    Here's wpsupercache.conf:
    Code:
    set $cache_uri $request_uri;
    
    
    # POST requests and urls with a query string should always go to PHP
    
    if ($request_method = POST) {
    
            set $cache_uri 'null cache';
    
    }
    
    
    if ($query_string != "") {
    
            set $cache_uri 'null cache';
    
    }
    
    
    # Don't cache uris containing the following segments
    
    if ($request_uri ~* "(/add-a-quote|/random-story|/contact-form|/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 'null cache';
    
    }
    
    
    # Don't use the cache for logged in users or recent commenters
    
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
    
            set $cache_uri 'null cache';
    
    }
    
     
  4. wlin

    wlin New Member

    9
    1
    3
    Apr 10, 2016
    Ratings:
    +1
    Local Time:
    6:12 AM
    Tried clearing cache again and I still get this on page load.

    <!-- Dynamic page generated in 0.564 seconds. -->
    <!-- Cached page generated by WP-Super-Cache on 2016-04-11 15:52:55 -->
    <!-- Compression = gzip -->
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,955
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,416
    Local Time:
    12:12 AM
    Nginx 1.13.x
    MariaDB 5.5
  6. wlin

    wlin New Member

    9
    1
    3
    Apr 10, 2016
    Ratings:
    +1
    Local Time:
    6:12 AM
    Yup I followed the instructions for that page.

    And I moved the conf above the root/location block and it's still doing it. Says it's cached in the HTML. But the thing is, if I turn off PHP, the page isn't cached and won't load. But the homepage and others that I haven't set in the config will work.
     
  7. eva2000

    eva2000 Administrator Staff Member

    30,955
    6,917
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,416
    Local Time:
    12:12 AM
    Nginx 1.13.x
    MariaDB 5.5
    might need to follow updated instructions specific for wp super cache at Wordpress Nginx Auto Installer (WP Super Cache)
     
  8. wlin

    wlin New Member

    9
    1
    3
    Apr 10, 2016
    Ratings:
    +1
    Local Time:
    6:12 AM