我目前正在致力于在 NGINX(反向代理)上启用缓存。
使用此配置,X-Proxy-Cache 的值始终为MISS。
我当前的conf(在/etc/nginx/conf.d中):
proxy_cache_path /data/nginx/cache/MON_URL levels=1:2 keys_zone=MY_ZONE:8m max_size=1000m inactive=24h;
upstream opera {
server MY_SERVER_IP:443;
}
server {
listen 80;
server_name MON_URL www.MON_URL;
return 301 https://MON_URL$request_uri;
}
server {
listen 443 ssl;
server_name www.MON_URL;
return 301 $scheme://MON_URL$request_uri;
}
server {
listen 443 ssl;
server_name MON_URL;
location / {
proxy_pass https://opera/;
rewrite ^/$ /OPERA/ last;
proxy_cache MY_ZONE;
proxy_cache_valid any 24h;
proxy_set_header Host $host;
add_header X-Proxy-Cache $upstream_cache_status;
}
location /robots.txt {
return 200 "User-agent: *\nDisallow: /";
} …
Run Code Online (Sandbox Code Playgroud)