httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/modules/experimental mod_cache.c
Date Mon, 25 Nov 2002 17:40:23 GMT
stoddard    2002/11/25 09:40:23

  Modified:    modules/experimental mod_cache.c
  Log:
  Log reason for cache decline.
  
  Revision  Changes    Path
  1.65      +46 -26    httpd-2.0/modules/experimental/mod_cache.c
  
  Index: mod_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.c,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- mod_cache.c	21 Nov 2002 21:52:47 -0000	1.64
  +++ mod_cache.c	25 Nov 2002 17:40:23 -0000	1.65
  @@ -460,7 +460,8 @@
           info = cache->info;
       }
       else {
  -
  +        char *reason = NULL;
  +        apr_pool_t *p = r->pool;
           /*
            * Pass Data to Cache
            * ------------------
  @@ -526,45 +527,64 @@
            * a whole lot of conditions that prevent us from caching this data.
            * They are tested here one by one to be clear and unambiguous. 
            */
  -
  -        /* RFC2616 13.4 we are allowed to cache 200, 203, 206, 300, 301 or 410
  -         * We don't cache 206, because we don't (yet) cache partial responses.
  -         * We include 304 Not Modified here too as this is the origin server
  -         * telling us to serve the cached copy.
  -         */
  -        if ((r->status != HTTP_OK && r->status != HTTP_NON_AUTHORITATIVE
  -             && r->status != HTTP_MULTIPLE_CHOICES
  -             && r->status != HTTP_MOVED_PERMANENTLY
  -             && r->status != HTTP_NOT_MODIFIED)
  +        if (r->status != HTTP_OK && r->status != HTTP_NON_AUTHORITATIVE
  +            && r->status != HTTP_MULTIPLE_CHOICES
  +            && r->status != HTTP_MOVED_PERMANENTLY
  +            && r->status != HTTP_NOT_MODIFIED) {
  +            /* RFC2616 13.4 we are allowed to cache 200, 203, 206, 300, 301 or 410
  +             * We don't cache 206, because we don't (yet) cache partial responses.
  +             * We include 304 Not Modified here too as this is the origin server
  +             * telling us to serve the cached copy.
  +             */
  +              reason = apr_pstrcat(p, "Response status %d", r->status);
  +        } 
  +        else if (exps != NULL && exp == APR_DATE_BAD) {
               /* if a broken Expires header is present, don't cache it */
  -            || (exps != NULL && exp == APR_DATE_BAD)
  +            reason = apr_pstrcat(p, "Broken expires header %s", exp);
  +        }
  +        else if (r->args && exps == NULL) {
               /* if query string present but no expiration time, don't cache it
                * (RFC 2616/13.9)
                */
  -            || (r->args && exps == NULL)
  +            reason = "Query string present but no expires header";
  +        }
  +        else if (r->status == HTTP_NOT_MODIFIED && (NULL == cache->handle))
{
               /* if the server said 304 Not Modified but we have no cache
                * file - pass this untouched to the user agent, it's not for us.
                */
  -            || (r->status == HTTP_NOT_MODIFIED && (NULL == cache->handle))
  +            reason = "HTTP Status 304 Not Modified";
  +        }
  +        else if (r->status == HTTP_OK && lastmods == NULL && etag ==
NULL 
  +                 && (conf->no_last_mod_ignore ==0)) {
               /* 200 OK response from HTTP/1.0 and up without a Last-Modified
                * header/Etag 
                */
               /* XXX mod-include clears last_modified/expires/etags - this
                * is why we have an optional function for a key-gen ;-) 
                */
  -            || (r->status == HTTP_OK && lastmods == NULL && etag ==
NULL 
  -                && (conf->no_last_mod_ignore ==0))
  +            reason = "No Last-Modified or Etag header";
  +        }
  +        else if (r->header_only) {
               /* HEAD requests */
  -            || r->header_only
  +            reason = "HTTP HEAD request";
  +        }
  +        else if (ap_cache_liststr(NULL, cc_out, "no-store", NULL)) {
               /* RFC2616 14.9.2 Cache-Control: no-store response
                * indicating do not cache, or stop now if you are
                * trying to cache it */
  -            || ap_cache_liststr(NULL, cc_out, "no-store", NULL)
  +            reason = "Cache-Control: no-store present";
  +        }
  +        else if (ap_cache_liststr(NULL, cc_out, "private", NULL)) {
               /* RFC2616 14.9.1 Cache-Control: private
                * this object is marked for this user's eyes only. Behave
                * as a tunnel.
                */
  -            || ap_cache_liststr(NULL, cc_out, "private", NULL)
  +            reason = "Cache-Control: private present";
  +        }
  +        else if (apr_table_get(r->headers_in, "Authorization") != NULL
  +                 && !(ap_cache_liststr(NULL, cc_out, "s-maxage", NULL)
  +                      || ap_cache_liststr(NULL, cc_out, "must-revalidate", NULL)
  +                      || ap_cache_liststr(NULL, cc_out, "public", NULL))) {
               /* RFC2616 14.8 Authorisation:
                * if authorisation is included in the request, we don't cache,
                * but we can cache if the following exceptions are true:
  @@ -572,16 +592,16 @@
                * 2) If Cache-Control: must-revalidate is included
                * 3) If Cache-Control: public is included
                */
  -            || (apr_table_get(r->headers_in, "Authorization") != NULL
  -                && !(ap_cache_liststr(NULL, cc_out, "s-maxage", NULL)
  -                     || ap_cache_liststr(NULL, cc_out, "must-revalidate", NULL)
  -                     || ap_cache_liststr(NULL, cc_out, "public", NULL)))
  +            reason = "Authorization required";
  +        }
  +        else if (r->no_cache) {
               /* or we've been asked not to cache it above */
  -            || r->no_cache) {
  +            reason = "no_cache present";
  +        }
   
  +        if (reason) {
               ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  -                         "cache: response is not cachable");
  -
  +                         "cache: response not cached. Reason: %s", reason);
               /* remove this object from the cache 
                * BillS Asks.. Why do we need to make this call to remove_url?
                * leave it in for now..
  
  
  

Mime
View raw message