我有一个PHP网站,有很多dynamic生成的网页。 我试图转向mod_cache来帮助提升性能,因为在大多数情况下,内容在特定的一天不会改变。
我已经尽可能地configuration了mod_cache,下面的例子是web上的例子,包括apache.org上的mod_cache页面 。 当我设置LogLevel debug ,我看到有关caching的一些信息[不]发生。 有很多这样的线对:
[Fri Jun 01 17:28:18 2012] [debug] mod_cache.c(141): Adding CACHE_SAVE filter for /foo/bar [Fri Jun 01 17:28:18 2012] [debug] mod_cache.c(148): Adding CACHE_REMOVE_URL filter for /foo/bar
这很好,因为我设置了CacheEnable disk /foo ,表示我希望在/ foocaching下的所有内容。 我是mod_cache的新手,但是我对这些行的理解是,它只是意味着mod_cache已经确认URL应该被caching,但是应该有更多的行表示它将数据保存到caching中,然后稍后在相同的URL上随后检索它们。
不pipe是用F5刷新还是不用,或者用不同的浏览器,或者不同的电脑,我都可以打到相同的URL。 总是在日志中显示的那对线,而不是别的。
当我设置CacheEnable disk / ,我看到更多的活动。 但我不想caching整个站点,并且网站有很多不同的子path,所以我不想修改代码来在所有必要的地方设置no-cache头。
我会提到mod_rewrite在这里被使用,把/ foo / bar改写成类似于index.php?baz=/foo/bar ,但是我的理解是mod_cache使用了重写前的URL,而不是重写后的URL。
据我所知,我有响应标题没有得到caching的方式。 以下是一个例子:
Cache-Control:must-revalidate, max-age=3600 Connection:Keep-Alive Content-Encoding:gzip Content-Length:16790 Content-Type:text/html Date:Fri, 01 Jun 2012 21:43:09 GMT Expires:Fri, 1 Jun 2012 18:43:09 -0400 Keep-Alive:timeout=15, max=100 Pragma: Server:Apache Vary:Accept-Encoding
mod_cacheconfiguration如下:
CacheRoot /var/cache/apache2/ CacheDirLevels 3 CacheDirLength 2 CacheEnable disk /foo
什么是在mod_cache做caching工作的方式?
这是我的configuration,它工作正常:
<IfModule mod_disk_cache.c> CacheEnable disk / CacheRoot /var/cache/apache2/mod_disk_cache CacheIgnoreCacheControl On CacheMaxFileSize 2500000 CacheIgnoreURLSessionIdentifiers jsessionid CacheIgnoreHeaders Set-Cookie </IfModule>
你需要有适合你需要的CacheIgnoreURLSessionIdentifiers,所以也许你需要PHP
CacheIgnoreURLSessionIdentifiers PHPSESSID
问候Janning
我正面临着同样的问题,试图映射
CacheEnable Disk /api
唯一的映射工作是
CacheEnable Disk /
哪个caching了一切。
尽pipe文档说mod_cache在url重写后运行,但没有。 为了得到它的工作,我改变了
CacheEnable Disk /index.php/api