【发布时间】:2014-11-25 04:30:57
【问题描述】:
我有 Rails 应用程序。它有部分 nginx 配置: 上游应用服务器 { 服务器 unix:/var/www/app/shared/unicorn.sock fail_timeout=0; }
server {
listen 80;
server_name app hostname;
keepalive_timeout 5;
root /var/www/app/current/public;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_pass http://app_server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_cache off;
}
location ~ /assets/*\.(png|gif|jpg|jpeg|css|js|swf|ico|gz)(\?[0-9]+)?$ {
access_log off;
}
}
我想缓存我的应用程序的几个页面(例如所有 *.json url)。我该怎么做?
根据 nginx 文档我不能:
- 在命名位置使用嵌套位置
- 在 if 块中使用 proxy_cache
【问题讨论】:
标签: nginx