httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1003331 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_cache.c modules/cache/mod_disk_cache.c
Date Thu, 30 Sep 2010 23:25:15 GMT
Author: minfrin
Date: Thu Sep 30 23:25:15 2010
New Revision: 1003331

URL: http://svn.apache.org/viewvc?rev=1003331&view=rev
Log:
mod_cache: Support the caching of HEAD requests.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/cache/mod_cache.c
    httpd/httpd/trunk/modules/cache/mod_disk_cache.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1003331&r1=1003330&r2=1003331&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Sep 30 23:25:15 2010
@@ -2,6 +2,8 @@
 
 Changes with Apache 2.3.9
 
+  *) mod_cache: Support the caching of HEAD requests. [Graham Leggett]
+
   *) htcacheclean: Allow the option to round up file sizes to a given
      block size, improving the accuracy of disk usage. [Graham Leggett]
 

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1003331&r1=1003330&r2=1003331&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Thu Sep 30 23:25:15 2010
@@ -852,10 +852,6 @@ static int cache_save_filter(ap_filter_t
          */
         reason = "No Last-Modified; Etag; Expires; Cache-Control:max-age or Cache-Control:s-maxage
headers";
     }
-    else if (r->header_only && !cache->stale_handle) {
-        /* Forbid HEAD requests unless we have it cached already */
-        reason = "HTTP HEAD request";
-    }
     else if (!conf->store_nostore &&
              ap_cache_liststr(NULL, cc_out, "no-store", NULL)) {
         /* RFC2616 14.9.2 Cache-Control: no-store response
@@ -1039,10 +1035,6 @@ static int cache_save_filter(ap_filter_t
      */
 
     /* Did we have a stale cache entry that really is stale?
-     *
-     * Note that for HEAD requests, we won't get the body, so for a stale
-     * HEAD request, we don't remove the entity - instead we let the
-     * CACHE_REMOVE_URL filter remove the stale item from the cache.
      */
     if (cache->stale_handle) {
         if (r->status == HTTP_NOT_MODIFIED) {
@@ -1051,7 +1043,7 @@ static int cache_save_filter(ap_filter_t
             info = &cache->handle->cache_obj->info;
             rv = OK;
         }
-        else if (!r->header_only) {
+        else {
             /* Oh, well.  Toss it. */
             cache->provider->remove_entity(cache->stale_handle);
             /* Treat the request as if it wasn't conditional. */
@@ -1065,8 +1057,8 @@ static int cache_save_filter(ap_filter_t
         }
     }
 
-    /* no cache handle, create a new entity only for non-HEAD requests */
-    if (!cache->handle && !r->header_only) {
+    /* no cache handle, create a new entity */
+    if (!cache->handle) {
         rv = cache_create_entity(cache, r, size, in);
         info = apr_pcalloc(r->pool, sizeof(cache_info));
         /* We only set info->status upon the initial creation. */

Modified: httpd/httpd/trunk/modules/cache/mod_disk_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_disk_cache.c?rev=1003331&r1=1003330&r2=1003331&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_disk_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_disk_cache.c Thu Sep 30 23:25:15 2010
@@ -391,6 +391,8 @@ static int create_entity(cache_handle_t 
     dobj->hdrs.file = header_file(r->pool, conf, dobj, key);
     dobj->vary.file = header_file(r->pool, conf, dobj, key);
 
+    dobj->disk_info.header_only = r->header_only;
+
     return OK;
 }
 
@@ -525,6 +527,14 @@ static int open_entity(cache_handle_t *h
 
     apr_file_close(dobj->hdrs.fd);
 
+    /* Is this a cached HEAD request? */
+    if (dobj->disk_info.header_only && !r->header_only) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
+                 "disk_cache: HEAD request cached, non-HEAD requested, ignoring: %s",
+                 dobj->hdrs.file);
+        return DECLINED;
+    }
+
     /* Open the data file */
     if (dobj->disk_info.has_body) {
         flags = APR_READ | APR_BINARY;
@@ -999,6 +1009,7 @@ static apr_status_t write_headers(cache_
     disk_info.status = h->cache_obj->info.status;
     disk_info.inode = dobj->disk_info.inode;
     disk_info.device = dobj->disk_info.device;
+    disk_info.header_only = dobj->disk_info.header_only;
 
     disk_info.name_len = strlen(dobj->name);
 



Mime
View raw message