大体配置是这样,想实现带 mycookie 这个 cookie 的 php 页面,添加 Cache-Control 这个 http 头:
server {
...
set $skip_cache 0;
if ($http_cookie ~* "mycookie") {
set $skip_cache 1;
}
location ~ [^/]\.php(/|$) {
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
if ($skip_cache = 1) {
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
}
}
}
发现加了下面这 3 行代码后, Cache-Control 头倒是出现了,但是 X-Frame-Options 和 X-Content-Type-Options 这两个 http 头不见了,删掉这 3 行代码后又出现:
if ($skip_cache = 1) {
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
}