nginx做反向代理时如何只缓存指定扩展名的文件

如题,请问在用nginx做反向代理时如何配置,以实现只缓存指定扩展名的文件?

nginx
2023-08-09 17:02:06
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Wandaer


写一个规则匹配location即可,比如:


location ~ ^/v3 {
    proxy_pass https://api.nuget.org;
    location ~ .nupkg$ {
        proxy_pass https://api.nuget.org;
        proxy_cache nuget-cache;
        proxy_cache_valid 2400h;
    }
}
分享
微博
QQ
微信
回复
2023-08-09 18:37:58
相关问题
HarmonyOS fs中获取文件扩展名方式
1520浏览 • 1回复 待解决
HarmonyOS 如何对库函数代理
505浏览 • 1回复 待解决
如何编写打 nginx dockerfile 文件
3845浏览 • 1回复 待解决
如何编写打 nginx dockerfile 文件?
4653浏览 • 1回复 待解决
如何用redis/memcache缓存层?
3060浏览 • 1回复 待解决
nginx缓存导致页面失效什么原因啊?
3201浏览 • 1回复 待解决
HarmonyOS 如何实现页面反向传值?
1324浏览 • 1回复 待解决
如何控制跑马灯反向滚动?
1177浏览 • 1回复 待解决