http://weizhifeng.net/nginx-proxy-cache.html
很棒的解說
Nginx效能解析
以apache為後端,Nginx為前端
Nginx將頁面圖片cache在本機來回應
#vi /etc/nginx/sites-available/default
server {
:
:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
#try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.1.168;
proxy_cache tmpcache;
proxy_cache_key "$scheme$request_method$host$request_uri";
proxy_cache_valid 200 304 1m;
//後端回應http_status_code 200和304的
//保留一分鐘
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_404;
//後端出問題時,以cache資料回應
#proxy_cache_revalidate on;
}
:
:
}
#vi /etc/nginx/nginx.conf
http {
:
:
##
# page cache
##
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=tmpcache:5m max_size=100m;
#proxy_temp_path /tmp/nginx/tmp 1 2; #option
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mkdir -p /tmp/nginx/cache
#mkdir -p /tmp/nginx/tmp
#service nginx restart
可以去比較前端Nginx與後端Apache的access.log
- Nov 12 Wed 2014 16:00
Nginx 當前端cache資料
文章標籤
全站熱搜
留言列表