使用mod_cache模块
- 在httpd.conf文件中添加以下代码:
LoadModule cache_module modules/mod_cache.so
- 配置反向代理服务器:
ProxyRequests Off
ProxyPreserveHost On
Order allow,deny
Allow from all
ProxyPass /api http://api.example.com
ProxyPassReverse /api http://api.example.com
- 在VirtualHost中启用缓存:
CacheEnable disk /
CacheRoot /var/cache/localhost/
CacheDefaultExpire 3600
CacheMaxFileSize 1000000
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On
CacheEnable disk
CacheHeader on
CacheDefaultExpire 120
CacheMaxFileSize 1000000
CacheLastModifiedFactor 0.5
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On