[openresty] srcache_store 无效

openresty 配置 srcache_store 后无效,找了很久都没找到原因,突然在日志中看到如下信息

srcache_store skipped due to response header "Content-Encoding: gzip" 
(maybe you forgot to disable compression on the backend?) 
while reading response header from upstream

查了下官方的说明
默认情况下,如果 response 的头中 Content-Encoding 不为空
则 openresty 不会触发 srcache_store

若要强制缓存则需要设置
srcache_ignore_content_encoding 为 on

还有一种解决思路
请求后端使用 proxy_set_header Accept-Encoding "";
这样后端就不会返回 gzip 后的页面了

官方参考文档

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。