You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2005/04/10 15:39:06 UTC

svn commit: r160771 - in httpd/httpd/branches/2.0.x: CHANGES STATUS docs/manual/mod/mod_cache.xml modules/experimental/cache_util.c modules/experimental/mod_cache.c modules/experimental/mod_cache.h modules/experimental/mod_disk_cache.c modules/experimental/mod_mem_cache.c

Author: striker
Date: Sun Apr 10 06:39:03 2005
New Revision: 160771

URL: http://svn.apache.org/viewcvs?view=rev&rev=160771
Log:
Backport.

* STATUS

  Remove vote.

* CHANGES
* docs/manual/mod/mod_cache.xml
* modules/experimental/cache_util.c
* modules/experimental/mod_cache.c
* modules/experimental/mod_cache.h
* modules/experimental/mod_mem_cache.c
* modules/experimental/mod_disk_cache.c

  Add CacheIgnoreHeaders directive.
  PR: 30399
    docs/manual/mod/mod_cache.xml: r1.18
    modules/experimental/cache_util.c: 1.36
    modules/experimental/mod_cache.c: 1.95
    modules/experimental/mod_cache.h: 1.52
    modules/experimental/mod_disk_cache.c: 1.67
    modules/experimental/mod_mem_cache.c: 1.119
      +1: jerenkrantz, stoddard, striker
      +0: sounds like a nice 'feature' v.s. rfc-required behavior, great for 2.2

Modified:
    httpd/httpd/branches/2.0.x/CHANGES
    httpd/httpd/branches/2.0.x/STATUS
    httpd/httpd/branches/2.0.x/docs/manual/mod/mod_cache.xml
    httpd/httpd/branches/2.0.x/modules/experimental/cache_util.c
    httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.c
    httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.h
    httpd/httpd/branches/2.0.x/modules/experimental/mod_disk_cache.c
    httpd/httpd/branches/2.0.x/modules/experimental/mod_mem_cache.c

Modified: httpd/httpd/branches/2.0.x/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/CHANGES?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/CHANGES (original)
+++ httpd/httpd/branches/2.0.x/CHANGES Sun Apr 10 06:39:03 2005
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.54
 
+  *) mod_cache: Add CacheIgnoreHeaders directive.  PR 30399.
+     [Rüiger Plü <r.pluem t-online.de>]
+
   *) mod_ldap: Added the directive LDAPConnectionTimeout to configure
      the ldap socket connection timeout value.  
      [Brad Nicholes]

Modified: httpd/httpd/branches/2.0.x/STATUS
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/STATUS?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/STATUS (original)
+++ httpd/httpd/branches/2.0.x/STATUS Sun Apr 10 06:39:03 2005
@@ -171,17 +171,6 @@
       +1: stoddard, striker, jim
       -1: brianp (we need a more robust solution than what's in 2.1 right now),
 
-    * mod_cache: Add CacheIgnoreHeaders directive.
-      PR: 30399
-        docs/manual/mod/mod_cache.xml: r1.18
-        modules/experimental/cache_util.c: 1.36
-        modules/experimental/mod_cache.c: 1.95
-        modules/experimental/mod_cache.h: 1.52
-        modules/experimental/mod_disk_cache.c: 1.67
-        modules/experimental/mod_mem_cache.c: 1.119
-      +1: jerenkrantz, stoddard, striker
-      +0: sounds like a nice 'feature' v.s. rfc-required behavior, great for 2.2
-
     * support/check_forensic: Fix tempfile usage
       svn rev 125495, 126224
       jerenkrantz says: r126224 fixes brokenness with r125495 on Solaris.

Modified: httpd/httpd/branches/2.0.x/docs/manual/mod/mod_cache.xml
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/docs/manual/mod/mod_cache.xml?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/docs/manual/mod/mod_cache.xml (original)
+++ httpd/httpd/branches/2.0.x/docs/manual/mod/mod_cache.xml Sun Apr 10 06:39:03 2005
@@ -333,4 +333,57 @@
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+<name>CacheIgnoreHeaders</name>
+<description>Do not store the given HTTP header(s) in the cache.
+</description>
+<syntax>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</syntax>
+<default>CacheIgnoreHeaders None</default>
+<contextlist><context>server config</context><context>virtual host</context>
+</contextlist>
+
+<usage>
+    <p>According to RFC 2616, hop-by-hop HTTP headers are not stored in
+    the cache.  The following HTTP headers are hop-by-hop headers and thus
+    do not get stored in the cache in <em>any</em> case regardless of the
+    setting of <directive>CacheIgnoreHeaders</directive>:</p>
+
+    <ul>
+      <li><code>Connection</code></li>
+      <li><code>Keep-Alive</code></li>
+      <li><code>Proxy-Authenticate</code></li>
+      <li><code>Proxy-Authorization</code></li>
+      <li><code>TE</code></li>
+      <li><code>Trailers</code></li>
+      <li><code>Transfer-Encoding</code></li>
+      <li><code>Upgrade</code></li>
+    </ul>
+
+    <p><directive>CacheIgnoreHeaders</directive> specifies additional HTTP
+    headers that should not to be stored in the cache.  For example, it makes
+    sense in some cases to prevent cookies from being stored in the cache.</p>
+
+    <p><directive>CacheIgnoreHeaders</directive> takes a space separated list
+    of HTTP headers that should not be stored in the cache. If only hop-by-hop
+    headers not should be stored in the cache (the RFC 2616 compliant
+    behaviour), <directive>CacheIgnoreHeaders</directive> can be set to
+    <code>None</code>.</p>
+
+    <example><title>Example 1</title>
+      CacheIgnoreHeaders Set-Cookie
+    </example>
+
+    <example><title>Example 2</title>
+      CacheIgnoreHeaders None
+    </example>
+
+    <note type="warning"><title>Warning:</title>
+      If headers like <code>Expires</code> which are needed for proper cache
+      management are not stored due to a
+      <directive>CacheIgnoreHeaders</directive> setting, the behaviour of
+      mod_cache is undefined.
+    </note>
+</usage>
+</directivesynopsis>
+
 </modulesynopsis>

Modified: httpd/httpd/branches/2.0.x/modules/experimental/cache_util.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/modules/experimental/cache_util.c?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/modules/experimental/cache_util.c (original)
+++ httpd/httpd/branches/2.0.x/modules/experimental/cache_util.c Sun Apr 10 06:39:03 2005
@@ -22,6 +22,8 @@
 
 /* -------------------------------------------------------------- */
 
+extern module AP_MODULE_DECLARE_DATA cache_module;
+
 /* return true if the request is conditional */
 CACHE_DECLARE(int) ap_cache_request_is_conditional(apr_table_t *table)
 {
@@ -518,8 +520,13 @@
  * headers table that are allowed to be stored in a cache.
  */
 CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
-                                                        apr_table_t *t)
+                                                        apr_table_t *t,
+                                                        server_rec *s)
 {
+    cache_server_conf *conf;
+    char **header;
+    int i;
+
     /* Make a copy of the headers, and remove from
      * the copy any hop-by-hop headers, as defined in Section
      * 13.5.1 of RFC 2616
@@ -534,5 +541,15 @@
     apr_table_unset(headers_out, "Trailers");
     apr_table_unset(headers_out, "Transfer-Encoding");
     apr_table_unset(headers_out, "Upgrade");
+
+    conf = (cache_server_conf *)ap_get_module_config(s->module_config,
+                                                     &cache_module);
+    /* Remove the user defined headers set with CacheIgnoreHeaders.
+     * This may break RFC 2616 compliance on behalf of the administrator.
+     */
+    header = (char **)conf->ignore_headers->elts;
+    for (i = 0; i < conf->ignore_headers->nelts; i++) {
+        apr_table_unset(headers_out, header[i]);
+    }
     return headers_out;
 }

Modified: httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.c?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.c (original)
+++ httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.c Sun Apr 10 06:39:03 2005
@@ -717,6 +717,9 @@
     ps->no_last_mod_ignore = 0;
     ps->ignorecachecontrol = 0;
     ps->ignorecachecontrol_set = 0 ;
+    /* array of headers that should not be stored in cache */
+    ps->ignore_headers = apr_array_make(p, 10, sizeof(char *));
+    ps->ignore_headers_set = CACHE_IGNORE_HEADERS_UNSET;
     return ps;
 }
 
@@ -753,6 +756,10 @@
         (overrides->ignorecachecontrol_set == 0)
         ? base->ignorecachecontrol
         : overrides->ignorecachecontrol;
+    ps->ignore_headers =
+        (overrides->ignore_headers_set == CACHE_IGNORE_HEADERS_UNSET)
+        ? base->ignore_headers
+        : overrides->ignore_headers;
     return ps;
 }
 static const char *set_cache_ignore_no_last_mod(cmd_parms *parms, void *dummy,
@@ -782,6 +789,34 @@
     return NULL;
 }
 
+static const char *add_ignore_header(cmd_parms *parms, void *dummy,
+                                     const char *header)
+{
+    cache_server_conf *conf;
+    char **new;
+
+    conf =
+        (cache_server_conf *)ap_get_module_config(parms->server->module_config,
+                                                  &cache_module);
+    if (!strncasecmp(header, "None", 4)) {
+        /* if header None is listed clear array */
+        conf->ignore_headers->nelts = 0;
+    }
+    else {
+        if ((conf->ignore_headers_set == CACHE_IGNORE_HEADERS_UNSET) ||
+            (conf->ignore_headers->nelts)) {
+            /* Only add header if no "None" has been found in header list
+             * so far.
+             * (When 'None' is passed, IGNORE_HEADERS_SET && nelts == 0.)
+             */
+            new = (char **)apr_array_push(conf->ignore_headers);
+            (*new) = header;
+        }
+    }
+    conf->ignore_headers_set = CACHE_IGNORE_HEADERS_SET;
+    return NULL;
+}
+
 static const char *add_cache_enable(cmd_parms *parms, void *dummy, 
                                     const char *type, 
                                     const char *url)
@@ -914,6 +949,9 @@
                   NULL, 
                   RSRC_CONF, 
                   "Ignore requests from the client for uncached content"),
+    AP_INIT_ITERATE("CacheIgnoreHeaders", add_ignore_header, NULL, RSRC_CONF,
+                    "A space separated list of headers that should not be "
+                    "stored by the cache"),
     AP_INIT_TAKE1("CacheLastModifiedFactor", set_cache_factor, NULL, RSRC_CONF,
                   "The factor used to estimate Expires date from "
                   "LastModified date"),

Modified: httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.h?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.h (original)
+++ httpd/httpd/branches/2.0.x/modules/experimental/mod_cache.h Sun Apr 10 06:39:03 2005
@@ -134,6 +134,12 @@
     /** ignore client's requests for uncached responses */
     int ignorecachecontrol;
     int ignorecachecontrol_set;
+    /** store the headers that should not be stored in the cache */
+    apr_array_header_t *ignore_headers;
+    /* flag if CacheIgnoreHeader has been set */
+    #define CACHE_IGNORE_HEADERS_SET   1
+    #define CACHE_IGNORE_HEADERS_UNSET 0
+    int ignore_headers_set;
 } cache_server_conf;
 
 /* cache info information */
@@ -257,7 +263,9 @@
 /* Create a new table consisting of those elements from a request_rec's
  * headers_out that are allowed to be stored in a cache
  */
-CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool, apr_table_t *t);
+CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
+                                                        apr_table_t *t,
+                                                        server_rec *s);
 
 /**
  * cache_storage.c

Modified: httpd/httpd/branches/2.0.x/modules/experimental/mod_disk_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/modules/experimental/mod_disk_cache.c?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/modules/experimental/mod_disk_cache.c (original)
+++ httpd/httpd/branches/2.0.x/modules/experimental/mod_disk_cache.c Sun Apr 10 06:39:03 2005
@@ -607,7 +607,8 @@
         if (r->headers_out) {
             apr_table_t *headers_out;
 
-            headers_out = ap_cache_cacheable_hdrs_out(r->pool, r->headers_out);
+            headers_out = ap_cache_cacheable_hdrs_out(r->pool, r->headers_out,
+                                                      r->server);
 
             if (!apr_table_get(headers_out, "Content-Type") &&
                 r->content_type) {
@@ -628,7 +629,8 @@
         if (r->headers_in) {
             apr_table_t *headers_in;
 
-            headers_in = ap_cache_cacheable_hdrs_out(r->pool, r->headers_in);
+            headers_in = ap_cache_cacheable_hdrs_out(r->pool, r->headers_in,
+                                                     r->server);
             rv = store_table(dobj->hfd, headers_in);
             if (rv != APR_SUCCESS) {
                 return rv;

Modified: httpd/httpd/branches/2.0.x/modules/experimental/mod_mem_cache.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.0.x/modules/experimental/mod_mem_cache.c?view=diff&r1=160770&r2=160771
==============================================================================
--- httpd/httpd/branches/2.0.x/modules/experimental/mod_mem_cache.c (original)
+++ httpd/httpd/branches/2.0.x/modules/experimental/mod_mem_cache.c Sun Apr 10 06:39:03 2005
@@ -745,13 +745,16 @@
     /* Precompute how much storage we need to hold the headers */
     rc = serialize_table(&mobj->header_out, 
                          &mobj->num_header_out, 
-                         ap_cache_cacheable_hdrs_out(r->pool, r->headers_out));   
+                         ap_cache_cacheable_hdrs_out(r->pool, r->headers_out,
+                                                     r->server));
     if (rc != APR_SUCCESS) {
         return rc;
     }
     rc = serialize_table(&mobj->err_header_out, 
                          &mobj->num_err_header_out, 
-                         ap_cache_cacheable_hdrs_out(r->pool, r->err_headers_out));   
+                         ap_cache_cacheable_hdrs_out(r->pool,
+                                                     r->err_headers_out,
+                                                     r->server));
     if (rc != APR_SUCCESS) {
         return rc;
     }