1

在 Apache 2.2 httpd 服务器后面,我有一个基于 java REST 的应用程序,提供这种服务:

GET /countries/canada

我想启用mod_mem_cache来加速这些服务:

CacheEnable mem /countries/*

是否可以使用通配符?
如果没有,有什么解决方案可以做到这一点?

4

1 回答 1

1

事实上,我们不需要通配符。

例如,如果定义了以下配置:

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,我禁用了所有默认行为并强制缓存!
你必须问问自己这是否是你的要求。

于 2015-06-10T11:16:40.070 回答