Используйте apache mod_mem_cache для кэширования остальных сервисов

За httpd-сервером Apache 2.2 у меня есть Java-REST-приложение с таким сервисом:

GET /countries/canada

Я бы хотел включить mod_mem_cache для ускорения таких сервисов:

CacheEnable mem /countries/*

Можно ли использовать подстановочный знак?
Если нет, то какое есть решение для этого?

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 я отключил все поведение по умолчанию и принудительно кешировать!!!
Вы должны спросить себя, если это ваше требование.

Другие вопросы по тегам