在Apache 2.2 httpd服务器后面,我有一个基于java rest的应用程序,具有这种服务:
GET /countries/canada
我想启用mod_mem_cache来加速这些服务:
CacheEnable mem /countries/*
可以使用通配符吗?
如果没有,有什么解决办法呢?
实际上,我们不需要通配符。
例如,如果a定义如下配置:
ProxyPass /jsontest/ http://echo.jsontest.com/
ProxyPassReverse /jsontest/ http://echo.jsontest.com/
<IfModule mod_cache.c>
<IfModule mod_mem_cache.c>
CacheEnable mem /jsontest/
CacheDefaultExpire 300
MCacheSize 1024000
MCacheMaxObjectCount 10000
MCacheMinObjectSize 1
MCacheMaxObjectSize 2048000
CacheStorePrivate On
CacheIgnoreNoLastMod On
CacheStoreNoStore On
CacheIgnoreCacheControl On
</IfModule>
</IfModule>
我可以请求:
http://localhost/jsontest/
或
http://localhost/jsontest/titi/tutu
和apache将存储每个响应并提供服务:
Incoming request is asking for an uncached version of /jsontest/, but we have been configured to ignore it and serve cached content anyway
mem_cache: Cached url: http://localhost:80/jsontest/?
Incoming request is asking for an uncached version of /jsontest/, but we have been configured to ignore it and serve cached content anyway
mod_cache.c(312): cache: serving /jsontest/
Incoming request is asking for an uncached version of /jsontest/titi/tutu, but we have been configured to ignore it and serve cached content anyway
mod_cache.c(753): cache: Caching url: /jsontest/titi/tutu
Incoming request is asking for an uncached version of /jsontest/titi/tutu, but we have been configured to ignore it and serve cached content anyway
mod_cache.c(312): cache: serving /jsontest/titi/tutu
小心:
与CacheStorePrivate, CacheIgnoreNoLastMod, CacheStoreNoStore和CacheIgnoreCacheControl,我禁用所有默认行为和强制缓存!
你得问问自己,这是不是你的要求。