如何禁用nginx缓存

时间:2013-09-11 02:39:05

标签: caching nginx

我试图禁用nginx缓存。我使用Wnmp(https://bitbucket.org/x64architecture/windows-nginx-mysql-php)并且每次重新加载任何php文件时我都需要等待几分钟才能在浏览器上进行更改。我试图在nginx.conf上做一些更改,但是不成功。这是我的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
}

由于

1 个答案:

答案 0 :(得分:2)

解决了我的问题...按照以下步骤手动安装:http://eksith.wordpress.com/2008/12/08/nginx-php-on-windows/ 使用纯nginx我可以在nginx.conf上禁用缓存