https://issues.apache.org/bugzilla/show_bug.cgi?id=47580

           Summary: mod_cache sends 200 response instead of 304
           Product: Apache httpd-2
           Version: 2.2.11
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_cache
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=24037)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24037)
PHP script to demonstrate the problem

If you make a conditional request for a cached document, but the document is
expired in the cache, mod_cache correctly passes on the conditional request to
the backend. If the backend responds with a "304 Not Modified" response that
indicates that the cached copy is still up to date, mod_cache serves the
contents of the cache to the client with a 200 code. This is a
standards-conforming valid way of responding.

But couldn't it just send a "304 Not Modified" code instead? RFC2616 14.26 says
"instead, if the request method was GET or HEAD, the server SHOULD respond with
a 304 (Not Modified) response, including the cache- related header fields
(particularly ETag) of one of the entities that matched." The current behaviour
unnecessarily sends a response body to the client. This ends up wasting
bandwidth in the case where you press refresh on an unmodified object (at least
in Firefox,) which sends these request headers:

If-None-Match="My ETag"
Cache-Control=max-age=0

I do not want the behaviour given by the "CacheIgnoreCacheControl yes"
directive. I still want mod_cache to validate the request against the backend,
but I don't want it to waste bandwidth by sending a 200 response code.

To test it, I have these cache-related lines in my virtual host definition:

CacheRoot C:/temp
CacheEnable disk /

My index.php is the attached file.

My web browser with an empty cache requests index.php, the (trimmed) response
is:

Status=OK - 200
Date=Mon, 20 Jul 2009 07:16:05 GMT
Expires=Wed, 19 Aug 2009 07:16:05 GMT
Etag="ComputedETag"

The log performed by index.php indicates:

Mon, 20 Jul 2009 19:16:05 +1200 - Response: 200. Generated document.

So far so good. But now I press refresh in my web browser. This makes a
conditional request for the document:

If-None-Match="ComputedETag"
Cache-Control=max-age=0

With the max-age of 0, the cache will be bypassed, which is the desired
behaviour. The cache passes this conditional request onto the backend, and the
backend logs it:

Mon, 20 Jul 2009 19:16:12 +1200 - Response: 304 Not Modified

So the backend is trying to tell the client that it already has an up-to-date
body. But the response sent to the client by mod_cache is:

Status=OK - 200
Date=Mon, 20 Jul 2009 07:16:12 GMT
Etag="ComputedETag"
Expires=Wed, 19 Aug 2009 07:16:12 GMT

My Apache configuratiion is:

Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i SVN/1.6.3 PHP/5.3.0

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to