如何禁用Nginx缓存 [英] How to disable nginx cache

查看:2024
本文介绍了如何禁用Nginx缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试禁用Nginx缓存.我正在使用Wnmp( https://bitbucket.org/x64architecture/windows-nginx-mysql-php ),每次我重新加载任何php文件时,我都需要等待几分钟,以使更改反映在浏览器上.我尝试对nginx.conf进行一些更改,但未成功.这是我的nginx.conf:

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
}

谢谢

推荐答案

解决了我的问题...请按照以下步骤手动安装:

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

这篇关于如何禁用Nginx缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆