我最近将我的 Ubuntu 11.10 x64 服务器升级到了 12.04。在此过程中,Squid 从 2.7 升级到了 3.1。Squid 3.1 有许多不同的选项,破坏了我的设置。因此,我彻底删除了 squid 2.7 和 3.1,从头开始。现在一切都像以前一样工作,除了一件事:使用 ?/variables 缓存 .swf 文件。Squid 3 将 ? 视为动态内容,并且不会缓存它。
例如,Squid 2.7 将 .swf 文件缓存在http://ninjakiwi.com/Games/Tower-Defense/Play/Bloons-Tower-Defense-5.html但 3.1 不是。
<object id="mov" name="movn" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="620">
<param name="movie" value="http://www.ninjakiwifiles.com/Games/gameswfs/btd5.swf?v=160512-2">
<param name="allowscriptaccess" value="always">
<param name="bgcolor" value="#000000">
<param name="flashvars" value="file=http://www.ninjakiwifiles.com/Games/gameswfs/btd5-dat.swf?v=280512">
<p>Get Flash play Ninja Kiwi games.</p>
</object>
这是因为“?v=160512-2”和“?v=280512”部分。此行应该负责:
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
但禁用它仍然不会缓存.swf 文件。
如何配置 Squid 3.1 来缓存这些文件?
我当前的配置是:
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
acl localnet src 192.168.2.0-192.168.2.254
acl localnet src 192.168.3.0-192.168.3.254
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all
http_port 3128
cache_dir ufs /var/spool/squid 10240 16 256
maximum_object_size 100 MB
coredump_dir /var/spool/squid3
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i \.(gif|png|jpg|jpeg|ico)$ 10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i \.(iso|avi|wav|mp3|mp4|mpeg|swf|flv|x-flv)$ 43200 90% 432000 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i \.(deb|rpm|exe|zip|tar|tgz|ram|rar|bin|ppt|doc|tiff)$ 10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i \.index.(html|htm)$ 0 40% 10080
refresh_pattern -i \.(html|htm|css|js)$ 1440 40% 40320
refresh_pattern Packages\.bz2$ 0 20% 4320 refresh-ims
refresh_pattern Sources\.bz2$ 0 20% 4320 refresh-ims
refresh_pattern Release\.gpg$ 0 20% 4320 refresh-ims
refresh_pattern Release$ 0 20% 4320 refresh-ims
refresh_pattern . 0 40% 40320
cache_effective_user proxy
cache_effective_group proxy
答案1
Squid 3.1 没有缓存查询参数所需的 storeurl_rewrite_program 参数。没有办法做到这一点。