0

I have setup apache2 with django and mod_wsgi in Debian Wheezy. I enabled mod_mem_cache with this configuration:

<IfModule mod_mem_cache.c>
    CacheEnable mem /
    MCacheSize 400000
    MCacheMaxObjectCount 100
    MCacheMinObjectSize 1
    MCacheMaxObjectSize 500000
    CacheIgnoreNoLastMod On
    CacheIgnoreHeaders Set-Cookie
</IfModule>

based on the fact that MCacheMaxStreamingBuffer is the smaller of 100000 or MCacheMaxObjectSize as stated in the docs.

When I try hitting a page with size 3.3KB I get these response headers in firebug:

Connection  Keep-Alive
Content-Encoding    gzip
Content-Type    text/html; charset=utf-8
Date    Wed, 27 Aug 2014 14:47:39 GMT
Keep-Alive  timeout=5, max=100
Server  Apache/2.2.22 (Debian)
Transfer-Encoding   chunked
Vary    Cookie,Accept-Encoding

and the page isn't served from cache. In the page source there is however the correct header 'Cache-Control: max-age=300,must-revalidate' but doesn't show up in firebug. In apache log I only see correctly:

[info] mem_cache: Cached url: https://83.212.**.**/?

With another test page that I created outside of django that doesn't have chunked encoding as a header, caching works fine. Why is the page not served from cache? Has anyone seen something similar?

  • You would get a chunked response due to a lack of a Content-Length header for the response. Normally Django would add a content length on responses. Is there anything special about how you are generating that page. For example, using StreamingHttpResponse explicitly when generating the response? – Graham Dumpleton Aug 28 '14 at 03:19
  • No I don't use StreamingHttpResponse and don't want to add Content-Length so a chunked response is normal in my case. The thing is why mod_cache is not serving in such a case; I thought that MCacheMaxStreamingBuffer exists to solve this problem with chunked encoding but it doesn't.. – eviekass Aug 28 '14 at 08:59
  • I changed from mod_mem_cache to mod_disk_cache and now it works..Don't know why but I will cache on disk for now. – eviekass Aug 28 '14 at 14:43

0 Answers0