• I am using WP Super Cache version 1.4.8 with Nginx.

    Important part of the nginx.conf:

    
    	server {
    		server_name testingtestingtesting.tld www.testingtestingtesting.tld;
    		listen 192.168.100.42;
    		root /home/account94/public_html;
    		index index.html index.htm index.php;
    		access_log /var/log/virtualmin/testingtestingtesting.tld_access_log;
    		error_log /var/log/virtualmin/testingtestingtesting.tld_error_log;
    
    # upload import file fix
    client_max_body_size 20M;
    
    		fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    		fastcgi_param SERVER_SOFTWARE nginx;
    		fastcgi_param QUERY_STRING $query_string;
    		fastcgi_param REQUEST_METHOD $request_method;
    		fastcgi_param CONTENT_TYPE $content_type;
    		fastcgi_param CONTENT_LENGTH $content_length;
    		fastcgi_param SCRIPT_FILENAME /home/account94/public_html$fastcgi_script_name;
    		fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    		fastcgi_param REQUEST_URI $request_uri;
    		fastcgi_param DOCUMENT_URI $document_uri;
    		fastcgi_param DOCUMENT_ROOT /home/account94/public_html;
    		fastcgi_param SERVER_PROTOCOL $server_protocol;
    		fastcgi_param REMOTE_ADDR $remote_addr;
    		fastcgi_param REMOTE_PORT $remote_port;
    		fastcgi_param SERVER_ADDR $server_addr;
    		fastcgi_param SERVER_PORT $server_port;
    		fastcgi_param SERVER_NAME $server_name;
    		fastcgi_param HTTPS $https;
    
    # BEGIN GZIP
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    # END GZIP
    
    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 ~* "(/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';
    }
    
    # Set the cache file
    set $cachefile "/wp-content/cache/supercache/$http_host/$cache_uri/index.html";
    if ($https ~* "on") {
        set $cachefile "/wp-content/cache/supercache/$http_host/$cache_uri/index-https.html";
    }
    
    # Add cache file debug info as header
    add_header X-Cache-File $cachefile;
    
    # Try in the following order: (1) cachefile, (2) normal url, (3) php
    location / {
        try_files $cachefile $uri $uri/ /index.php;
    }
    
    #        location / {
    #			try_files $uri $uri/ /index.php?$args; 
    #        }
    		location ~ \.php$ {
    			try_files $uri =404;
    			fastcgi_pass unix:/var/php-nginx/148519495327014.sock/socket;
    		}
    		listen 192.168.100.42:443 ssl;
    		ssl_certificate /home/account94/ssl.cert;
    		ssl_certificate_key /home/account94/ssl.key;
    		listen [::];
    		listen [::]:443 ssl;
    	}
    
    

    Screenshots:

    screenshot 1

    screenshot 2
    It says that creating cache files is working, but files are not created.

    Cache files are created without problems when anonymous users visit the website.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tedj14

    (@tedj14)

    I tested it with

    
    wget -v -r -nc --no-parent --no-check-certificate mytestingwebiste.tld
    

    and caching works (it caches the pages that are visited by the wget).

    The only problem is that preload is not working (despite there is an indication in plugin’s control panel that it works – see the screenshot above).

    Thread Starter tedj14

    (@tedj14)

    I changed the URL of the website to http:// (it was https:// with self-signed certificate).

    It stared to work, but when it made 111 cached pages the counter did not move (I also check this on the filesystem, not only on “Contents” tab).

    
    $ find /home/account94/public_html/wp-content/cache/ |  grep \.gz | wc -l
    111
    
    
    Full refresh of cache in 0 hours 14 minutes and 25 seconds.
    
    Currently caching from post 300 to 400.
    
    Page last cached: 366 https://reasonableobservers.ml/how-did-garcinia-cambogia-gain-its-fat-burning-reputation.html
    

    The URL above is still “https:// …” despite I changed the settings in “General” (WordPress Address (URL) and Site Address (URL)). Maybe because I am accessing the WordPress Dashboard with https protocol.

    I am testing it now with http Dashboard…

    It made 165 cached pages so far.

    It looks like there is an problem when the plugin is trying to visit the pages in order to activate the caching – it stops if certificate is self signed.

    Thread Starter tedj14

    (@tedj14)

    It gives error only when this checkbox is not checked:

    screenshot

    • This reply was modified 9 years, 4 months ago by tedj14.
    Thread Starter tedj14

    (@tedj14)

    The problem was SSL certificate. If certificate is self-signed or not valid it did not work.

    Also, visitors with user agent “WordPress/* example.com” should not be served with cached content without invoking PHP.

    
    if ($http_user_agent ~* ^WordPress.*\ example\.com$ ) {
      set $cache_uri 'null cache';
    }
    

    Or more simple code (but will serve other WordPress sites without caching – for example, when another WP site request RSS it will not be cached):

    
    if ($http_user_agent ~* WordPress ) {
      set $cache_uri 'null cache';
    }
    

    Context of this code can be found here.

    • This reply was modified 9 years, 4 months ago by tedj14.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Preload does not work (I am using Nginx)’ is closed to new replies.