我正在尝试配置NGINX服务器以缓存我的文件。但是,尽管有我的配置,文件仍然具有“ Pragma:no-cache”头。我相信这就是导致所有X-Cache-Status标头都变为MISS的原因。
CURL OUTPUT它显示了Pragma的两个标题,我相信这是导致此X-Cache-Status导致MISS的原因。
我的配置似乎正确,有什么问题吗?我想念什么吗?如果需要,我还可以提供我的nginx.conf。 非常感谢您的帮助。
server {
listen 80;
# Redirect www to non-www
if ( $host ~ ^www\.(?<domain>.+) ) {
rewrite ^/(.*)$ $scheme://$domain/$1;
}
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen *:443;
server_name example.com *.example.com; # edit this to your domain
# SSL config
ssl on;
ssl_certificate /root/ssl/m
ssl_certificate_key /root/ssl/ #these are all edited for stackoverflow.
location / {
proxy_cache edge-cache;
proxy_pass http://example.com/;
proxy_cache_key $scheme$host$proxy_host$request_uri;
proxy_redirect https://example.com/ https://example.com/;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_cache_valid 15m;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_revalidate on;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
add_header X-Handled-By $proxy_host;
add_header Pragma "cache";
add_header Cache-Control "max-age=604800, public";
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_hide_header Set-Cookie;
proxy_hide_header Cache-Control;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
add_header X-Cache-Status $upstream_cache_status;
client_max_body_size 10m;
client_body_buffer_size 128k;
access_log off;
log_not_found off;
expires 30d;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}