Squid 从不使用 dnf 缓存文件

Squid 从不使用 dnf 缓存文件

我正在尝试为 dnf 设置本地存储库缓存。这个想法是让网络上的一台机器下载一个包,然后网络上任何其他尝试获取该包的机器都会从缓存中接收它。我为此使用了 squid,目前 dnf 通过 squid 服务器请求包,但 squid 每次都记录未命中。我不确定是什么原因造成的,所以我将复制典型的 access.log 消息和 squid.conf 的相关部分。

1450150756.680    131 10.64.9.57 TCP_MISS/200 183815 GET 
http://mirror.crucial.com.au/fedora/linux/updates/23/x86_64/l/libquadmath-5.3.1-2.fc23.x86_64.rpm - 
FIRSTUP_PARENT/[parent-proxy-url] application/x-redhat-package-manager 
[Host: mirror.crucial.com.au
User-Agent: dnf/1.1.4
Accept: */*
Proxy-Connection: Keep-Alive] 
[HTTP/1.1 200 OK
Expires: Sun, 13 Dec 2015 22:57:47 GMT
Server: nginx/1.8.0
Date: Tue, 15 Dec 2015 03:39:07 GMT
Content-Type: application/x-redhat-package-manager
Content-Length: 183182
Last-Modified: Thu, 10 Dec 2015 20:53:32 GMT
ETag: "5669e64c-2cb8e"
Age: 0
Connection: keep-alive
Proxy-Connection: keep-alive
Via: 1.1 NZ8KS49CH
X-Cache-Lookup: HIT from NZ8KS49CH (M86 Security Proxy Cache)
X-Cache: HIT from NZ8KS49CH (M86 Security Proxy Cache)
X-WebMarshal-RequestID: C3F30882-D914-481F-8E60-2AD367A4A046]

这是配置:

cache_peer [parent-proxy-url] parent 8081 0 no-query no-digest proxy-only default login=[user]:[pass]

acl all src 0.0.0.0/0 ::/0
never_direct allow all
maximum_object_size 4096 MB
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 10000 16 256

# Leave coredumps in the first cache dir
#coredump_dir /var/spool/squid

cache_replacement_policy heap LFUDA

acl filetype urlpath_regex \.rpm
cache allow filetype
send_hit allow filetype
cache deny all

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern -i .rpm$ 129600 100% 129600 refresh-ims override-expire
refresh_pattern -i .iso$ 129600 100% 129600 refresh-ims override-expire
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

我还注意到,当我设置好 Web 浏览器并通过 squid 进行定向时,有些内容会被缓存。一旦我设置了仅 dnf,就不会再缓存任何内容。

答案1

搞定了。cache_peer 行包含“proxy-only”,这会阻止 squid 缓存来自该对等点的任何内容。删除“proxy-only”一词可完全解决该问题。我想我是从网上某个教程中学到的,该教程肯定尝试了与我不同的东西。

相关内容