带有 VirtualHost 代理的 Apache 2.4 缓存
Apache 2.4 Cache with VirtualHost Proxy
我想为 Tomcat 上的网站激活 Apache 2.4 上的缓存,该网站通过具有 VirtualHost 配置的 Apache。
这是我的 apache2.config 文件代码:
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
#Cache
CacheEnable disk /
CacheHeader on
CacheIgnoreNoLastMod On
CacheDefaultExpire 800
CacheMaxExpire 64000
ExpiresActive on
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8084/Application/
ProxyPassReverse / http://localhost:8084/Application/
</VirtualHost>
缓存在我的本地机器 (Ubuntu) 中有效,但在生产服务器 (Ubuntu 服务器) 中无效。
基本上我用
检查缓存目录
ls -la /var/cache/apache2/mod_cache_disk/
在我的本地机器上,我得到了很多具有正确日期的缓存文件,但在我的服务器上,目录仍然是空的。
任何想法,谢谢
- 是否启用了缓存模块?如果是这样,您将看到您正在使用的那些指令名称
httpd -L | grep -i cache
- 您的缓存目录的权限设置是否正确?
ls -lZ yourdir # check selinux
getfacl yourdir # check for the account running the process
- 这些资源是否被授权缓存? 运行 一个
curl
命令并查找缓存 headers (pragma
, cache-control
)
我发现了问题。基本上我没有启用"cache_disk"。我不明白为什么 apache 重新启动而不给我一个错误。这就是为什么我没有考虑它。无论如何,解决方案是
sudo a2enmod cache_disk
我想为 Tomcat 上的网站激活 Apache 2.4 上的缓存,该网站通过具有 VirtualHost 配置的 Apache。
这是我的 apache2.config 文件代码:
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
#Cache
CacheEnable disk /
CacheHeader on
CacheIgnoreNoLastMod On
CacheDefaultExpire 800
CacheMaxExpire 64000
ExpiresActive on
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8084/Application/
ProxyPassReverse / http://localhost:8084/Application/
</VirtualHost>
缓存在我的本地机器 (Ubuntu) 中有效,但在生产服务器 (Ubuntu 服务器) 中无效。
基本上我用
检查缓存目录ls -la /var/cache/apache2/mod_cache_disk/
在我的本地机器上,我得到了很多具有正确日期的缓存文件,但在我的服务器上,目录仍然是空的。
任何想法,谢谢
- 是否启用了缓存模块?如果是这样,您将看到您正在使用的那些指令名称
httpd -L | grep -i cache
- 您的缓存目录的权限设置是否正确?
ls -lZ yourdir # check selinux
getfacl yourdir # check for the account running the process
- 这些资源是否被授权缓存? 运行 一个
curl
命令并查找缓存 headers (pragma
,cache-control
)
我发现了问题。基本上我没有启用"cache_disk"。我不明白为什么 apache 重新启动而不给我一个错误。这就是为什么我没有考虑它。无论如何,解决方案是
sudo a2enmod cache_disk