2
我想通过使用自定义标头来实现我的脚本中的自定义nginx缓存控制方法:“Do-Cache”。Nginx缓存绕过自定义响应标头
map $sent_http_do_cache $nocache {
public 0;
default 1;
}
而在Nginx的服务器块: 我在Nginx的HTTP模块使用
fastcgi_cache_bypass $nocache;
fastcgi_no_cache $nocache;
因此,对于Do-Cache: public
,nginx的应缓存响应。否则不是。
但是这种配置不起作用。通过调试成日志,$sent_http_do_cache
和$nocache
的值是正确的,直到它们用于nginx的服务器块。如果在服务器块(fastcgi_cache_bypass $nocache
或简单的set $a $nocache
)中使用它们,则$nocache
变量获得“1”值,$sent_http_do_cache
- “ - ”。
是否有任何其他方式来管理基于自定义标头的nginx缓存?