How to disable nginx cache

2019-06-24 00:12发布

问题:

Im trying to disable nginx cache. Im using Wnmp (https://bitbucket.org/x64architecture/windows-nginx-mysql-php) and every time I reload any php file I need to wait some minutes to changes reflect on browser. I tried to make some changes on nginx.conf, but unsuccessful. Here is my nginx.conf:

worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}
http {
include       mime.types;
default_type  application/octet-stream;

access_log  logs/access.log;

sendfile        off;

#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  30;
    ssl_session_timeout 10m;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3;
    ssl_ciphers ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH; 
    ssl_prefer_server_ciphers on;
gzip  off;
server {
listen 80; # IPv4
server_name localhost;

## Parameterization using hostname of access and log filenames.
access_log logs/localhost_access.log;
error_log logs/localhost_error.log;

## Root and index files.
root html;
index  index.php index.html index.htm;

location / {
    try_files $uri $uri/ /index.php?r=$request_uri;
    expires -1;
}

location ~ ^/(protected|framework|themes/\w+/views) {
    deny  all;
}

#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    try_files $uri =404;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~* \.html$ {
expires -1;
}
location ~ \.php {
    fastcgi_split_path_info  ^(.+\.php)(.*)$;

    #let yii catch the calls to unexising PHP files
    set $fsn /;
    if (-f $document_root$fastcgi_script_name){
        set $fsn $fastcgi_script_name;
    }

    fastcgi_pass   127.0.0.1:9000;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;

    #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
    fastcgi_param  PATH_INFO        $fastcgi_path_info;
    fastcgi_param  PATH_TRANSLATED  $document_root$fsn;

expires -1;
}
    # prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
    location ~ /\. {
         deny all;
         access_log off;
         log_not_found off;
    }
} # end http server
}

Thanks

回答1:

Solved my problem... Installed manually following this steps: http://eksith.wordpress.com/2008/12/08/nginx-php-on-windows/ with pure nginx i could disable cache on nginx.conf



标签: caching nginx