2016-04-01 76 views
0

我的配置我nginx如下:nginx的缓存总是返回X-代理缓存:MISS

curl -X GET -I 192.168.1.193/css/style.css 

proxy_cache_path /v01/nginx levels=1:2 keys_zone=my_zone:10m inactive=60m; 
proxy_cache_key "$scheme$request_method$host$request_uri"; 

server { 
    listen 80 default_server; 
    listen [::]:80 default_server ipv6only=on; 

    root /usr/share/nginx/html; 
    index index.html index.htm; 
    charset utf-8; 

    server_name localhost; 

    location/{ 
     client_max_body_size 2M; 
     proxy_cache my_zone; 
     proxy_cache_bypass $http_cache_control; 
     add_header X-Proxy-Cache $upstream_cache_status; 
     include proxy_params; 
     proxy_pass http://localhost:3000; 
    } 
} 

我这个配置中安装nginx/1.4.6 (Ubuntu)一台机器,我与测试它的工作,与头X-Proxy-Cache: HIT

但是我在另一台安装了nginx/1.6.2 (Ubuntu),curl -X GET -I 192.168.1.97/css/style.css的机器上进行配置总是返回X-Proxy-Cache: MISS

我检查路径/v01/nginx,它什么也没有。

回答

0

我发现这里的问题是:

我并不在另一台机器设置的node.js缓存在我的项目,我改变

app.use express.static config.root + '/public' 

app.use express.static config.root + '/public', {maxAge: 1000 * 3600 * 24 * 7}