Apache 反向缓存代理 - 为什么它不缓存?
我正在尝试为广告图形(GIF、JPEG、SWF)服务设置反向缓存代理。 代理工作正常并将请求发送到原始服务器,但我似乎无法弄清楚为什么内容没有被缓存。 我当前的配置如下。 目标是缓存与 /ca/
URI 前缀匹配的所有请求。 源服务器使用干净的 URL 提供文件,没有文件扩展名,在源服务器标头上设置了缓存控制 max-age=1
周。
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_disk_cache.c>
CacheEnable disk /
CacheRoot "/var/cache/mod_proxy"
CacheDirLevels 3
CacheDirLength 5
CacheIgnoreCacheControl On
</IfModule>
RewriteCond %{REQUEST_URI} ^/ca/*
RewriteRule ^/(.*)$ http://origin.webserver.com/$1 [P,L]
目前,我所看到的唯一实际发生的缓存是在代理服务器上访问的本地文件,我正在寻找我缺少的内容来获取从要缓存的源服务器获取的内容。
我想知道这是否与 mod_cache 不缓存有关,因为内容是从原始服务器获取的,而不是在磁盘上的位置。
我正在寻找一种方法来强制缓存与该前缀匹配的所有请求。
PS 看起来我遇到了这个问题: [电子邮件受保护]%3E。 我将检查我的权限并查看调试消息......
I am attempting to set up a reverse caching proxy for ad graphics (GIF, JPEG, SWF) serving. The proxying is working fine and sending the request on to the origin server, but I can’t seem to figure out why the content isn't being cached. My current config is below. The goal is to cache all requests that match the /ca/
URI prefix. The origin server is serving the files with clean URLs, no file extensions, Cache-control max-age=1
week set on the origin server headers.
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_disk_cache.c>
CacheEnable disk /
CacheRoot "/var/cache/mod_proxy"
CacheDirLevels 3
CacheDirLength 5
CacheIgnoreCacheControl On
</IfModule>
RewriteCond %{REQUEST_URI} ^/ca/*
RewriteRule ^/(.*)$ http://origin.webserver.com/$1 [P,L]
Currently, the only caching I’ve seen actually happen is that of local files accessed on the proxy servers, I’m looking for what I’m missing to get content fetched from the origin server to be cached.
I’m wondering if it has to do with mod_cache
not caching because the content is fetched from the origin server, and not on a location on disk.
I am looking for a way to force all requests matching that prefix to be cached.
P.S. It looks like I’m having this exact issue: http://mail-archives.apache.org/mod_mbox/httpd-users/200901.mbox/%[email protected]%3E. I will be checking my permissions and go over debug messages…
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加这些指令似乎使缓存机制启动。 我认为这与从源服务器发送的过期和缓存控制标头有关,因为我使用 Symfony/PHP5 提供图像,而不是直接从文件系统提供图像。
Adding these directives seemed to kick the cache mechanism into gear. I figure it has to do with expiration and cache-control headers as sent from the origin server since I'm serving up images with Symfony/PHP5 instead of directly from the filesystem.