AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1075372

Alex's questions

Martin Hope
Alex
Asked: 2024-02-14 16:32:12 +0800 CST

无法使用 Squid 缓存动态内容

  • 5

我正在尝试使用鱿鱼来缓存一些动态内容。内容来自诸如 之类的请求/path/{id},其中id是资源的标识符。我尝试过使用鱿鱼的配置文件,但到目前为止还没有成功。

它可以缓存“/path/resource”之类的内容,但对于动态内容不起作用。充满access.log了TCP_MISS_ABORTED.

这是我的配置文件:

#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8     # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10      # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16     # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12      # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16     # RFC 1918 local private network (LAN)
acl localnet src fc00::/7           # RFC 4193 local private network range
acl localnet src fe80::/10          # RFC 4291 link-local (directly plugged) machines
acl dynamic_content urlpath_regex ^/long_text/get/[0-9]+

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

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# This default configuration only allows localhost requests because a more
# permissive Squid installation could introduce new attack vectors into the
# network by proxying external TCP connections to unprotected services.
http_access allow localhost
http_access allow dynamic_content

# Protect web applications running on the same server as Squid. They often
# assume that only local users can access them at "localhost" ports.
http_access allow to_localhost
http_access allow all

# Squid normally listens to port 3128
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256

# Leave coredumps in the first cache dir
cache_mem 1000 MB
maximum_object_size 4 MB
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern .       0   20% 4320

debug_options ALL,1 33,2

此外,出于测试原因,squid 服务与发出请求的客户端以及 Web 服务器在同一台服务器上运行。

编辑:对象不大于 1.5 MB

Edit2:访问日志如下所示:

1707899048.785      6 192.168.100.150 TCP_MISS/200 12592 GET http://192.168.100.150:8080/long_text/get/113 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.793      7 192.168.100.150 TCP_MISS_ABORTED/200 8488 GET http://192.168.100.150:8080/long_text/get/1868 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.806     11 192.168.100.150 TCP_MISS_ABORTED/200 20800 GET http://192.168.100.150:8080/long_text/get/743 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.814      8 192.168.100.150 TCP_MISS_ABORTED/200 20800 GET http://192.168.100.150:8080/long_text/get/1 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.821      5 192.168.100.150 TCP_MISS_ABORTED/200 8488 GET http://192.168.100.150:8080/long_text/get/1412 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.828      6 192.168.100.150 TCP_MISS_ABORTED/200 12592 GET http://192.168.100.150:8080/long_text/get/566 - HIER_DIRECT/192.168.100.150 text/plain

他们中的大多数是TCP_MISS_ABORTED,我想说只有百分之一是TCP_MISS,但我得到的不是TCP_MEM_HIT。

编辑:由网络服务器作为响应发送的完整标头:

Cache-Control: max-age=60
Content-Type: text/plain; charset=utf-8
Date: Wed, 14 Feb 2024 09:25:32 GMT
Transfer-Encoding: chunked

编辑:连续获取相同资源的日志:

1707902670.872     18 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904558.006     12 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904558.777     11 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904559.535     15 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904560.233     11 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
squid
  • 1 个回答
  • 53 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve