简体   繁体   English

使用apache mod_mem_cache缓存Rest服务

[英]Use apache mod_mem_cache to cache Rest services

Behind Apache 2.2 httpd server, i have a java REST-based application with this kind of service : 在Apache 2.2 httpd服务器后面,我有一个基于Java REST的应用程序,具有以下服务:

GET /countries/canada

I'd like to enable mod_mem_cache to speed up these services like that : 我想启用mod_mem_cache来加快这些服务的速度:

CacheEnable mem /countries/*

Is it possible to use wildcard ? 是否可以使用通配符?
If not, what is there any solution to do that ? 如果没有,有什么解决方案吗?

In fact, we don't need wildcard. 实际上,我们不需要通配符。

For example, if a defined the following configuration : 例如,如果定义了以下配置:

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>

I can request : 我可以要求:

http://localhost/jsontest/  

or 要么

http://localhost/jsontest/titi/tutu  

and apache will store each response and serve them : 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

Be carefull : 小心点 :

With CacheStorePrivate, CacheIgnoreNoLastMod, CacheStoreNoStore and CacheIgnoreCacheControl, i disabled all default behavior and force cache !!! 使用CacheStorePrivate,CacheIgnoreNoLastMod,CacheStoreNoStore和CacheIgnoreCacheControl,我禁用了所有默认行为并强制缓存!
You have to ask yourself if it is your requirement. 您必须问自己是否是您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM