请求头说明
proxy_hide_header ensures the header will not be passed back to the client,
proxy_ignore_headers ensures that the header will not automatically disable caching within nginx
其他问题
- 如果没有设置 proxy_cache_valid 字段,则不会缓存,请求被缓存策略拦截成功,但是一直miss
- proxy_cache_bypass可以根据uri或者其他策略对一些请求不缓存
- 一个server下有多个不同location proxy_pass到不同后端web server,怎么对这个server下所有环境都做缓存,如果server内共享一个缓存location,那么缓存未找到时候proxy_pass需要配置什么地址去回源资源,有以下解决方案:
a. 对每个不同的location都做一个缓存配置。如果环境数量少是可以这样配置的
b. 共用一个location缓存配置,再proxy_pass前面增加一段lua脚本,当执行到这里的时候,根据客户端请求的主机名去查到对应的真实web server,并且赋值给变量,所以proxy_pass只需要配置变量就行了
评论