2013-09-11 103 views
4

我試圖禁用nginx緩存。即時通訊使用Wnmp(https://bitbucket.org/x64architecture/windows-nginx-mysql-php),每次我重新加載任何PHP文件,我需要等待幾分鐘,以反映在瀏覽器上的變化。我試圖在nginx.conf上做一些修改,但不成功。這裏是我的nginx.conf:如何禁用nginx緩存

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 
} 

感謝

+0

禁用緩存什麼工作框架你在使用,爲什麼你懷疑nginx而不是瀏覽器或框架的工作?因爲我不認爲nginx默認有任何緩存。 –

+0

希望這有助於:http://serverfault.com/q/549200 – wpcoder

回答