Apache cache serving partial content 206 responses to requests for the full content

apache-2.2cachemod-cacheplone

We're running Plone 3.3.6 behind Apache 2.2.19 with mod_cache. We've recently noticed that Apache is caching the 206 response to a range request and then serving that partial response when a request for the full resource is made.

What seems to happen:

  • some client makes a range request for a resource that is not yet in the cache or is in the cache but has expired
  • Apache serves the 206 response correctly
  • another client makes a standard request the same resource
  • Apache serves the same 206 response to this second client: it should serve the entire response with a 200

This is causing problems with our css on some sites very occasionally

I can replicate this consistently: I wrote a little python script to make a range request.

I don't think we're not doing anything out of the ordinary with our Apache configuration. We're using reverse proxy configuration to serve pages from Plone. The Apache configuration relevant to mod_cache is as follows:

CacheEnable disk /
CacheDisable /static
CacheDisable /sitemap.xml.gz
CacheDisable /robots.txt
CacheIgnoreHeaders Set-Cookie

UseCanonicalName On

RequestHeader edit Accept-Encoding ^.*gzip.*$ gzip early
RequestHeader edit Accept-Encoding ^(?!gzip).*$ "" early

The Apache caching guide doesn't include 206 responses in the list of status codes the response "must have" for it to be cached. Is this a bug in Apache or are we doing something wrong in the configuration?

Best Answer

This is apache bug 49113 and has been fixed in the trunk but not in 2.2.19.