You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Oliver <oh...@gmail.com> on 2012/03/25 19:37:16 UTC

[users@httpd] Cached responses in mod_cache/mod_mem_cache not always sent

Hi all,

I've just started using mod_mem_cache to selectively cache some
responses on some of my systems and I'm not seeing the cached
responses sent back consistently. I know the responses are being
cached, thanks to the debug-level logging but they are not always
being sent out even if they could. I don't know if this is a low-load
optimisation Apache makes when it would be better to send a fresh
response to the client but the inconsistency is driving me insane.

Testing methodology:
 - Primary platform CentOS 5.6 with included Apache 2.2.3-63.el5.centos.1
 - Also tested: current Apache 2.2.22.
 - mod_mem_cache configuration:

        <IfModule mod_mem_cache.c>
                CacheEnable mem /
                CacheDefaultExpire 300
                MCacheSize 1024000
                MCacheMaxObjectCount 10000
                MCacheMinObjectSize 1
                MCacheMaxObjectSize 2048000
                CacheIgnoreNoLastMod On
        </IfModule>

My test file is a very small file (originally 256KB, now just a string
of text I can read out with curl). I can make numerous requests and
only after a while see a cached response:


[Sun Mar 25 10:19:51 2012] [debug] mod_cache.c(131): Adding CACHE_SAVE
filter for /testfile
[Sun Mar 25 10:19:51 2012] [debug] mod_cache.c(138): Adding
CACHE_REMOVE_URL filter for /testfile
[Sun Mar 25 10:19:51 2012] [debug] mod_cache.c(639): cache: Caching
url: /testfile
[Sun Mar 25 10:19:51 2012] [debug] mod_cache.c(645): cache: Removing
CACHE_REMOVE_URL filter.
[Sun Mar 25 10:19:51 2012] [info] mem_cache: Cached url:
http://localhost:8139/testfile?
....
.... (many of these repeated)
....
[Sun Mar 25 10:20:10 2012] [debug] mod_cache.c(131): Adding CACHE_SAVE
filter for /testfile
[Sun Mar 25 10:20:10 2012] [debug] mod_cache.c(138): Adding
CACHE_REMOVE_URL filter for /testfile
[Sun Mar 25 10:20:10 2012] [debug] mod_cache.c(639): cache: Caching
url: /testfile
[Sun Mar 25 10:20:10 2012] [debug] mod_cache.c(645): cache: Removing
CACHE_REMOVE_URL filter.
[Sun Mar 25 10:20:10 2012] [info] mem_cache: Cached url:
http://localhost:8139/testfile?
[Sun Mar 25 10:20:11 2012] [debug] mod_cache.c(282): cache: running
CACHE_OUT filter
[Sun Mar 25 10:20:11 2012] [debug] mod_cache.c(296): cache: serving /testfile

The requests are always the same:
# curl http://localhost:8139/testfile -v

Most of the time I get no cached response:

< HTTP/1.1 200 OK
< Date: Sun, 25 Mar 2012 17:20:10 GMT
< Server: Apache/2.2.22 (Unix)
< Last-Modified: Sun, 25 Mar 2012 15:36:44 GMT
< ETag: "73a02-15-4bc13065cfb00"
< Accept-Ranges: bytes
< Content-Length: 21
< Connection: close
< Content-Type: text/plain; charset=UTF-8
this is test content

Occasionally I'll get the cached response:

< HTTP/1.1 200 OK
< Date: Sun, 25 Mar 2012 17:20:11 GMT
< Server: Apache/2.2.22 (Unix)
< Last-Modified: Sun, 25 Mar 2012 15:36:44 GMT
< ETag: "73a02-15-4bc13065cfb00"
< Accept-Ranges: bytes
< Content-Length: 21
< Age: 30
< Connection: close
< Content-Type: text/plain; charset=UTF-8
this is test content

Note that the only distinction here is the Age header that is being
sent back. Even stranger, I can make a bunch of requests and the Age
header doesn't even increment uniformly with time. It seems as though
somehow internally the same item is being cached multiple times but
the request hits one of multiple caches depending on some "random"
factor.

Am I going insane? Have I not read the manual? Am I just stupid? (all three?)

Any assistance would be very much appreciated.
Oliver.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Cached responses in mod_cache/mod_mem_cache not always sent

Posted by Eric Covener <co...@gmail.com>.
I believe each process has it's own separate in-memory cache, does
that explain all your other observations?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Cached responses in mod_cache/mod_mem_cache not always sent

Posted by Oliver <oh...@gmail.com>.
Eric Covener wrote:
>
> I believe each process has it's own separate in-memory cache, does
> that explain all your other observations?

Yes it does, and I read that in the manual about 10 minutes after
writing this post, but only having subscribed to the digest I couldn't
immediately respond. Thanks for the help!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org