varnish 清理缓存 purge和ban
2016-10-30 20:02
127 查看
【软件版本】
varnish 4.x
参考:https://www.varnish-cache.org/docs/4.1/users-guide/purging.html
【分析purge 和 ban的区别】
共同点:
清除缓存
不同点:
purge 是一个动作 执行对访问的url在缓存中进行purge 清除。 一次只能对一个url
ban 是一个策略,必须先增加ban禁止策略,下次访问匹配到这个禁止策略的时候,不会去缓存中找,直接去fetch后面的。ban能清理匹配到的任何内容。
purge比较好理解,ban看官网的一段解释
官方原文:
There is another way to invalidate content: Bans. You can think of bans as a sort of a filter on objects already in the cache. You
翻译:
这个是(清除)无效内容的另一个方法: Bans. 你能将bans作为一个排序过的过滤缓存中的对象。你禁止某些内容来自你的缓存中。你能禁止的内容是我们缓存中的任何元数据。ban 仅仅工作在已经缓存的对象上,它不能阻止一个新的内容条目将被缓存。(我理解的意思是 ban只能使用一次,即一次性清理)
【用法】
purge的用法:
1 vcl配置文件中添加purge允许
2 curl -I - X PURGE http://10.59.74.33/123.jpg
ban的用法:
添加一个ban到禁止list中。
1 varnishadm -S /etc/varnish/secret -T 127.0.0.1:8080 'ban req.url ~ "0*.jpg$"'
当访问任何0*.jpg的uri的时候,将不会从缓存中取,直接去后端取(其实就是禁止使用缓存,换句话就是达到了 清除缓存的目的,这个就是squid没有设计到的,因为squid的清理只有purge 只能是执行动作去清理(一个很大的目录需要很多cpu),而不是想办法去匹配到禁止的url然后不去进入缓存中去取,达到相同的目的。)
varnish 4.x
参考:https://www.varnish-cache.org/docs/4.1/users-guide/purging.html
【分析purge 和 ban的区别】
共同点:
清除缓存
不同点:
purge 是一个动作 执行对访问的url在缓存中进行purge 清除。 一次只能对一个url
ban 是一个策略,必须先增加ban禁止策略,下次访问匹配到这个禁止策略的时候,不会去缓存中找,直接去fetch后面的。ban能清理匹配到的任何内容。
purge比较好理解,ban看官网的一段解释
官方原文:
There is another way to invalidate content: Bans. You can think of bans as a sort of a filter on objects already in the cache. You
bancertain content from being served from your cache. You can ban content based on any metadata we have. A ban will only work on objects already in the cache, it does not prevent new content from entering the cache or being served.Support for bans is built into Varnish and available in the CLI interface. To ban every png object belonging on example.com, issue the following command:
ban req.http.host == "example.com" && req.url ~ "\\.png$"
翻译:
这个是(清除)无效内容的另一个方法: Bans. 你能将bans作为一个排序过的过滤缓存中的对象。你禁止某些内容来自你的缓存中。你能禁止的内容是我们缓存中的任何元数据。ban 仅仅工作在已经缓存的对象上,它不能阻止一个新的内容条目将被缓存。(我理解的意思是 ban只能使用一次,即一次性清理)
【用法】
purge的用法:
1 vcl配置文件中添加purge允许
2 curl -I - X PURGE http://10.59.74.33/123.jpg
ban的用法:
添加一个ban到禁止list中。
1 varnishadm -S /etc/varnish/secret -T 127.0.0.1:8080 'ban req.url ~ "0*.jpg$"'
当访问任何0*.jpg的uri的时候,将不会从缓存中取,直接去后端取(其实就是禁止使用缓存,换句话就是达到了 清除缓存的目的,这个就是squid没有设计到的,因为squid的清理只有purge 只能是执行动作去清理(一个很大的目录需要很多cpu),而不是想办法去匹配到禁止的url然后不去进入缓存中去取,达到相同的目的。)
相关文章推荐
- linux + nginx + ngx_cache_purge 缓存清理
- lua实现nginx proxy_store的purge缓存清理的方法
- varnish ban方法批量清缓存
- 清理多个varnish服务器缓存的脚本
- 如何清理asp站点缓存的代码?
- Yii清理缓存的方法
- Varnish搭建缓存代理提高网站访问速度
- IOS清理缓存的几种方法
- ajax同步与异步加载和缓存清理设置
- 关于清理JBoss服务器端jsp文件缓存的问题
- Varnish purges 缓存清除技术研究
- Android特效专辑(七)——飞机升空特效,一键清理缓存,灵活运用动画会有不一样的感受
- 0122 ---清理缓存
- Android特效专辑(七)——飞机升空特效,一键清理缓存,灵活运用属性动画
- linux下的缓存机制及清理buffer/cache/swap的方法梳理
- 提高性能的Varnish缓存方案
- 缓存varnish配置详解
- 有关浏览器页面缓存的清理
- linux下清理缓存,以释放内存
- Varnish缓存机制详细介绍及简单配置