我正在尝试将Apache设置为具有caching的转发代理,但似乎没有正常工作。 获得Apache作为一个转发代理是没有问题的,但是不pipe我做什么,它都不会caching任何内容到磁盘或内存。 我已经检查过,确保mods_enabled目录中没有任何与mod_cache冲突(最终将其全部注释掉),并且我尝试将所有与caching相关的字段移动到mod_cache的configuration文件中。 另外,我为caching请求设置了日志logging,但是没有任何内容正在写入这些日志。 下面是我的Apacheconfiguration,任何帮助将不胜感激!
<VIRTUALHOST *:8080> ProxyRequests On ProxyVia On #ErrorLog "/var/log/apache2/proxy-error.log" #CustomLog "/var/log/apache2/proxy-access.log" common CustomLog "/var/log/apache2/cached-requests.log" common env=cache-hit CustomLog "/var/log/apache2/uncached-requests.log" common env=cache-miss CustomLog "/var/log/apache2/revalidated-requests.log" common env=cache-revalidate CustomLog "/var/log/apache2/invalidated-requests.log" common env=cache-invalidate LogFormat "%{cache-status}e ..." # This path must be the same as the one in /etc/default/apache2 CacheRoot /var/cache/apache2/mod_disk_cache # This will also cache local documents. It usually makes more sense to # put this into the configuration for just one virtual host. CacheEnable disk / #CacheHeader on CacheDirLevels 3 CacheDirLength 5 ##<IfModule mod_mem_cache.c> # CacheEnable mem / # MCacheSize 4096 # MCacheMaxObjectCount 100 # MCacheMinObjectSize 1 # MCacheMaxObjectSize 2048 #</IfModule> <Proxy *> Order deny,allow Deny from all Allow from xxxx #IP above hidden for this post <filesMatch "\.(xml|txt|html|js|css)$"> ExpiresDefault A7200 Header append Cache-Control "proxy-revalidate" </filesMatch> </Proxy> </VIRTUALHOST>
这是一个旧的post,但我发现它希望find我自己的答案,所以我会分享我可以,也许它是有用的。
鉴于你所说的话,我会:
确认它甚至可以caching一些东西,强制它caching所有内容并检查caching目录是否为空( 完整示例 ):
CacheIgnoreNoLastMod打开
CacheDefaultExpire 7200
如果上述不起作用,那么我相信这个问题不是mod_cache或mod_disk_cache。 如果是这样的话,请停下来,否则继续:
确保没有Cache-Control私有或无存储标头。 如果有,请在“标题追加”之前添加以下内容:
标题未设置caching控制
确保有“Etag”,“Last-Modified”或“Expires”标题。 (也许你可以从代理的公共端请求检查mod_expire实际上是否设置了expires头文件?)
在一个侧面说明,我有磁盘caching工作,但我也一直无法弄清楚如何让%{caching状态}显示在日志中。