0

I'm using wordpress with WP Super Cache, and this is my nginx rules:

server {
    server_name  website.com;
    location / {
        root   /var/www/html/website.com;
        index  index.php;
           if (-f $request_filename) {
                   break;
           }
           set $supercache_file '';
           set $supercache_uri $request_uri;
           if ($request_method = POST) {
                   set $supercache_uri '';
           }
           if ($query_string) {
                   set $supercache_uri '';
           }
           if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
                   set $supercache_uri '';
           }
           if ($supercache_uri ~ ^(.+)$) {
                   set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
           }
           if (-f $document_root$supercache_file) {
                   rewrite ^(.*)$ $supercache_file break;
           }
           if (!-e $request_filename) {
                   rewrite . /index.php last;
           }
    }
    location ~ \.php$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME /var/www/html/website.com$fastcgi_script_name;
            include         fastcgi_params;
    }
}

But I need it uncached if visitor come from some website. (for example: from google.com and yahoo.com)

2 Answers 2

1

This nginx module might do what you want.

0

you can try

server {
    server_name  website.com;
    location / {
        root   /var/www/html/website.com;
        index  index.php;
           if ($http_referer ~* (|google.com|google.co|yahoo.com|) ) {
                   rewrite . /index.php last;
           }
           if (-f $request_filename) {
                   break;
           }
           set $supercache_file '';
           set $supercache_uri $request_uri;
           if ($request_method = POST) {
                   set $supercache_uri '';
           }
           if ($query_string) {
                   set $supercache_uri '';
           }
           if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
                   set $supercache_uri '';
           }
           if ($supercache_uri ~ ^(.+)$) {
                   set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
           }
           if (-f $document_root$supercache_file) {
                   rewrite ^(.*)$ $supercache_file break;
           }
           if (!-e $request_filename) {
                   rewrite . /index.php last;
           }
    }
    location ~ \.php$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME /var/www/html/website.com$fastcgi_script_name;
            include         fastcgi_params;
    }
}

You must log in to answer this question.