Squid 客户端清除实用程序

发布于 2024-08-20 02:10:08 字数 1549 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

美人骨 2024-08-27 02:10:09

Apache Traffic Server v6.0.0 添加了一个“缓存生成 ID”,可以根据重映射规则进行设置。因此,您可以免费有效地清除整个“站点”,除了使旧版本不可用之外,它实际上没有做任何其他事情。

这与 ATS 缓存配合得很好,因为它是一个循环缓存(我们称之为旋风缓存),对象永远不会被主动删除,只是“丢失”。

使用这个新选项相当简单,例如,

map http://example.com http://real.example.com \
   @plugin=conf_remap.so \
   proxy.config.http.cache.generation=1

要立即(零成本)清除 example.com 的所有缓存条目,只需将生成 ID 更改为 2,然后以正常方式重新加载配置即可。

我还应该说,编写一个从 remap.config 之外的其他(外部)源加载这些生成 ID 的插件将非常容易。

Apache Traffic Server v6.0.0 adds a "cache generation ID" which can be set per remap rule. So you can effectively purge an entire "site" at no cost at all, it really doesn't do anything other than making the old versions unavailable.

This works well with the ATS cache, because it's a cyclical cache (we call it cyclone cache), objects are never actively removed, just "lost".

Using this new option is fairly straight forward, e.g.

map http://example.com http://real.example.com \
   @plugin=conf_remap.so \
   proxy.config.http.cache.generation=1

To instantly (zero cost) purge all cached entries for example.com, simply bump the generation ID to 2, and reload the configuration the normal way.

I should also say that writing a plugin that loads these generation IDs from some other (external) source other than our remap.config would be very easy.

还不是爱你 2024-08-27 02:10:08

我在搞乱这条线方面取得了有限的成功:

awk '{print $7}' /var/log/squid/access.log | grep www.example.com | sort | uniq | xargs -n 1 squidclient -m PURGE -s

I've had limited success messing with this line:

awk '{print $7}' /var/log/squid/access.log | grep www.example.com | sort | uniq | xargs -n 1 squidclient -m PURGE -s
徒留西风 2024-08-27 02:10:08

首先感谢 KimVais 建议我在 serverfault 中询问,我在那里找到了解决方案。

正如 serverfault 中的回答:

第 3 方清除实用程序将完全执行您所寻求的操作:

purge 工具是一种放大镜,可以查看您的squid-2 缓存。您可以使用 purge 查看缓存中的哪个文件中存储了哪些 URL。清除工具还可用于释放 URL 与用户指定的正则表达式匹配的对象。一个更麻烦的功能是删除鱿鱼似乎不再知道的文件的能力。

对于我们的加速(反向)代理,我使用如下配置:

purge -c /etc/squid/squid.conf -p localhost:80 -P0 -se 'http://www.mysite.com/'
-P0 将显示 URL 列表但不删除它们;将其更改为 -P1 以将 PURGE 发送到缓存,就像您在示例中所做的那样。

First of all thank you KimVais for advising me to ask in serverfault, I have found a solution there.

as answered in serverfault:

The 3rd-party purge utility will do exactly what you seek:

The purge tool is a kind of magnifying glass into your squid-2 cache. You can use purge to have a look at what URLs are stored in which file within your cache. The purge tool can also be used to release objects which URLs match user specified regular expressions. A more troublesome feature is the ability to remove files squid does not seem to know about any longer.

For our accelerating (reverse) proxy, I use a config like this:

purge -c /etc/squid/squid.conf -p localhost:80 -P0 -se 'http://www.mysite.com/'
-P0 will show the list of URLs but not remove them; change it to -P1 to send PURGE to the cache, as you do in your example.

陈甜 2024-08-27 02:10:08

net-purge gem 添加了 Net::HTTP::Purge到 ruby​​,这样你就可以轻松地清除缓存。

require 'net-purge'

Net::HTTP.start('417east.com') {|http|
  request = Net::HTTP::Purge.new('/')
  response = http.request(request)
  puts response.body # Guru Meditation
}

The net-purge gem adds Net::HTTP::Purge to ruby, so you can easily purge your cache.

require 'net-purge'

Net::HTTP.start('417east.com') {|http|
  request = Net::HTTP::Purge.new('/')
  response = http.request(request)
  puts response.body # Guru Meditation
}
最丧也最甜 2024-08-27 02:10:08

我想补充一点,没有O(1)方法可以使 Squid 缓存中的多个对象无效。有关详细信息,请参阅Squid 常见问题解答

相比之下,Nginx 和 Apache Traffic Server 似乎也缺乏此功能。 OTOH,Varnish 实现了禁止< /strong>,实际上应该做你想做的事。

I'd like to add that there's no O(1) way to do invalidate multiple objects in Squid cache. See the Squid FAQ for details.

For comparison, Nginx and Apache Traffic Server seem to lack this feature, too. OTOH, Varnish implements banning, which in practice should do what you want.

奈何桥上唱咆哮 2024-08-27 02:10:08

我们有很多清理的方法。我总是使用的示例 2 方法:

对于使用 MacOS 或 Linux 的客户端:

curl -X PURGE http://URL.of.Site/ABC.txt

直接在运行 Squid 的服务器上:

squidclient -m PURGE http://URL.of.Site/ABC.txt

当然,squid.conf 必须添加

acl Purge method PURGE
http_access allow localhost Purge
http_access allow localnet Purge
http_access deny Purge

We have a lot of ways to purge. Example 2 ways I alway use:

With client using MacOS or Linux:

curl -X PURGE http://URL.of.Site/ABC.txt

Direct on server which is running Squid:

squidclient -m PURGE http://URL.of.Site/ABC.txt

Absolutely, squid.conf must add

acl Purge method PURGE
http_access allow localhost Purge
http_access allow localnet Purge
http_access deny Purge
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文