diff options
author | Graham Leggett <minfrin@apache.org> | 2010-10-01 01:25:15 +0200 |
---|---|---|
committer | Graham Leggett <minfrin@apache.org> | 2010-10-01 01:25:15 +0200 |
commit | 44b825b72c706977f38148281dd9643e5809a0e0 (patch) | |
tree | f0fc4f1ecf612e885dc48ee9685002326936dbfb /modules/cache | |
parent | Add a TODO item for the 1.3 docs. (diff) | |
download | apache2-44b825b72c706977f38148281dd9643e5809a0e0.tar.xz apache2-44b825b72c706977f38148281dd9643e5809a0e0.zip |
mod_cache: Support the caching of HEAD requests.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1003331 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/cache')
-rw-r--r-- | modules/cache/mod_cache.c | 14 | ||||
-rw-r--r-- | modules/cache/mod_disk_cache.c | 11 |
2 files changed, 14 insertions, 11 deletions
diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 1313306d06..d3f1929411 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -852,10 +852,6 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) */ 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 *f, apr_bucket_brigade *in) */ /* 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 *f, apr_bucket_brigade *in) 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 *f, apr_bucket_brigade *in) } } - /* 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. */ diff --git a/modules/cache/mod_disk_cache.c b/modules/cache/mod_disk_cache.c index 8c3402d831..5b483995a6 100644 --- a/modules/cache/mod_disk_cache.c +++ b/modules/cache/mod_disk_cache.c @@ -391,6 +391,8 @@ static int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr 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, request_rec *r, const char *key) 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_handle_t *h, request_rec *r) 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); |