View | Details | Raw Unified | Return to bug 30399
Collapse All | Expand All

(-)httpd-2.0.53.orig/docs/manual/mod/mod_cache.xml (+53 lines)
Lines 333-336 will complete caching the file even if t Link Here
333
</usage>
333
</usage>
334
</directivesynopsis>
334
</directivesynopsis>
335
335
336
<directivesynopsis>
337
<name>CacheIgnoreHeaders</name>
338
<description>Do not store the given HTTP header(s) in the cache.
339
</description>
340
<syntax>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</syntax>
341
<default>CacheIgnoreHeaders None</default>
342
<contextlist><context>server config</context><context>virtual host</context>
343
</contextlist>
344
345
<usage>
346
    <p>According to RFC 2616 only hop-by-hop HTTP headers are not stored in
347
    the cache. The following HTTP headers are hop-by-hop headers and thus
348
    do not get stored in the cache in <em>any</em> case regardless of the
349
    setting of <directive>CacheIgnoreHeaders</directive>:</p>
350
351
    <ul>
352
      <li><code>Connection</code></li>
353
      <li><code>Keep-Alive</code></li>
354
      <li><code>Proxy-Authenticate</code></li>
355
      <li><code>Proxy-Authorization</code></li>
356
      <li><code>TE</code></li>
357
      <li><code>Trailers</code></li>
358
      <li><code>Transfer-Encoding</code></li>
359
      <li><code>Upgrade</code></li>
360
    </ul>
361
362
    <p><directive>CacheIgnoreHeaders</directive> allows to add additional HTTP
363
    headers that should not to be stored in the cache. For example it makes
364
    sense in some cases to prevent cookies from being stored in the cache.</p>
365
366
    <p><directive>CacheIgnoreHeaders</directive> takes a space separated list
367
    of HTTP headers that should not be stored in the cache. If all none
368
    hop-by-hop headers should be stored in the cache (RFC 2616 compliant
369
    behaviour), <directive>CacheIgnoreHeaders</directive> can be set to
370
    <code>None</code>.</p>
371
372
    <example><title>Example 1</title>
373
      CacheIgnoreHeaders Set-Cookie
374
    </example>
375
376
    <example><title>Example 2</title>
377
      CacheIgnoreHeaders None
378
    </example>
379
380
    <note type="warning"><title>Warning:</title>
381
      If headers like <code>Expires</code> that are needed for the cache
382
      management are not stored due to a
383
      <directive>CacheIgnoreHeaders</directive> setting, the behaviour of
384
      mod_cache is undefined.
385
    </note>
386
</usage>
387
</directivesynopsis>
388
336
</modulesynopsis>
389
</modulesynopsis>
(-)httpd-2.0.53.orig/modules/experimental/cache_util.c (-1 / +17 lines)
Lines 22-27 Link Here
22
22
23
/* -------------------------------------------------------------- */
23
/* -------------------------------------------------------------- */
24
24
25
extern module cache_module;
26
25
/* return true if the request is conditional */
27
/* return true if the request is conditional */
26
CACHE_DECLARE(int) ap_cache_request_is_conditional(apr_table_t *table)
28
CACHE_DECLARE(int) ap_cache_request_is_conditional(apr_table_t *table)
27
{
29
{
Lines 518-525 CACHE_DECLARE(char *)generate_name(apr_p Link Here
518
 * headers table that are allowed to be stored in a cache.
520
 * headers table that are allowed to be stored in a cache.
519
 */
521
 */
520
CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
522
CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool,
521
                                                        apr_table_t *t)
523
                                                        apr_table_t *t,
524
                                                        server_rec *s)
522
{
525
{
526
    cache_server_conf *conf;
527
    char **header;
528
    int i;
529
523
    /* Make a copy of the headers, and remove from
530
    /* Make a copy of the headers, and remove from
524
     * the copy any hop-by-hop headers, as defined in Section
531
     * the copy any hop-by-hop headers, as defined in Section
525
     * 13.5.1 of RFC 2616
532
     * 13.5.1 of RFC 2616
Lines 534-538 CACHE_DECLARE(apr_table_t *)ap_cache_cac Link Here
534
    apr_table_unset(headers_out, "Trailers");
541
    apr_table_unset(headers_out, "Trailers");
535
    apr_table_unset(headers_out, "Transfer-Encoding");
542
    apr_table_unset(headers_out, "Transfer-Encoding");
536
    apr_table_unset(headers_out, "Upgrade");
543
    apr_table_unset(headers_out, "Upgrade");
544
    conf = (cache_server_conf *)ap_get_module_config(s->module_config,
545
                                                     &cache_module);
546
    /* Remove the user defined headers set with CacheIgnoreHeaders.
547
     * This may break RFC 2616 compliance on behalf of the users wish.
548
     */
549
    header = (char **)conf->ignore_headers->elts;
550
    for (i = 0; i < conf->ignore_headers->nelts; i++) {
551
        apr_table_unset(headers_out, header[i]);
552
    }
537
    return headers_out;
553
    return headers_out;
538
}
554
}
(-)httpd-2.0.53.orig/modules/experimental/mod_cache.c (+36 lines)
Lines 717-722 static void * create_cache_config(apr_po Link Here
717
    ps->no_last_mod_ignore = 0;
717
    ps->no_last_mod_ignore = 0;
718
    ps->ignorecachecontrol = 0;
718
    ps->ignorecachecontrol = 0;
719
    ps->ignorecachecontrol_set = 0 ;
719
    ps->ignorecachecontrol_set = 0 ;
720
    /* array of headers that should not be stored in cache */
721
    ps->ignore_headers = apr_array_make(p, 10, sizeof(char *));
722
    ps->ignore_headers_set = CACHE_IGNORE_HEADERS_UNSET;
720
    return ps;
723
    return ps;
721
}
724
}
722
725
Lines 753-758 static void * merge_cache_config(apr_poo Link Here
753
        (overrides->ignorecachecontrol_set == 0)
756
        (overrides->ignorecachecontrol_set == 0)
754
        ? base->ignorecachecontrol
757
        ? base->ignorecachecontrol
755
        : overrides->ignorecachecontrol;
758
        : overrides->ignorecachecontrol;
759
    ps->ignore_headers =
760
        (overrides->ignore_headers_set == CACHE_IGNORE_HEADERS_UNSET)
761
        ? base->ignore_headers
762
        : overrides->ignore_headers;
756
    return ps;
763
    return ps;
757
}
764
}
758
static const char *set_cache_ignore_no_last_mod(cmd_parms *parms, void *dummy,
765
static const char *set_cache_ignore_no_last_mod(cmd_parms *parms, void *dummy,
Lines 782-787 static const char *set_cache_ignore_cach Link Here
782
    return NULL;
789
    return NULL;
783
}
790
}
784
791
792
static const char *add_ignore_header(cmd_parms *parms, void *dummy,
793
                                     const char *header)
794
{
795
    cache_server_conf *conf;
796
    char **new;
797
798
    conf =
799
        (cache_server_conf *)ap_get_module_config(parms->server->module_config,
800
                                                  &cache_module);
801
    if (!strncasecmp(header, "None", 4)) {
802
        /* if header None is listed clear array */
803
        conf->ignore_headers->nelts = 0;
804
    }
805
    else {
806
        if ((conf->ignore_headers_set == CACHE_IGNORE_HEADERS_UNSET) ||
807
            (conf->ignore_headers->nelts)) {
808
            /* Only add header if no "None" has been found in header list
809
             * so far.
810
             */
811
            new = (char **)apr_array_push(conf->ignore_headers);
812
            (*new) = header;
813
        }
814
    }
815
    conf->ignore_headers_set = CACHE_IGNORE_HEADERS_SET;
816
    return NULL;
817
}
818
785
static const char *add_cache_enable(cmd_parms *parms, void *dummy, 
819
static const char *add_cache_enable(cmd_parms *parms, void *dummy, 
786
                                    const char *type, 
820
                                    const char *type, 
787
                                    const char *url)
821
                                    const char *url)
Lines 914-919 static const command_rec cache_cmds[] = Link Here
914
                  NULL, 
948
                  NULL, 
915
                  RSRC_CONF, 
949
                  RSRC_CONF, 
916
                  "Ignore requests from the client for uncached content"),
950
                  "Ignore requests from the client for uncached content"),
951
    AP_INIT_ITERATE("CacheIgnoreHeaders", add_ignore_header, NULL, RSRC_CONF,
952
                    "A space separated list of headers that should not be stored by the cache"),
917
    AP_INIT_TAKE1("CacheLastModifiedFactor", set_cache_factor, NULL, RSRC_CONF,
953
    AP_INIT_TAKE1("CacheLastModifiedFactor", set_cache_factor, NULL, RSRC_CONF,
918
                  "The factor used to estimate Expires date from "
954
                  "The factor used to estimate Expires date from "
919
                  "LastModified date"),
955
                  "LastModified date"),
(-)httpd-2.0.53.orig/modules/experimental/mod_cache.h (-1 / +12 lines)
Lines 134-139 typedef struct { Link Here
134
    /** ignore client's requests for uncached responses */
134
    /** ignore client's requests for uncached responses */
135
    int ignorecachecontrol;
135
    int ignorecachecontrol;
136
    int ignorecachecontrol_set;
136
    int ignorecachecontrol_set;
137
    /** store the headers that should not be stored in the cache */
138
    apr_array_header_t *ignore_headers;
139
    /* flag if CacheIgnoreHeader has been set
140
     * FIXME: defined as 2 state variable as a starting point
141
     * for a later migration of complete / complete_set, no_last_mod_ignore
142
     * / no_last_mod_ignore_set, ignorecachecontrol / ignorecachecontrol_set
143
     * to three state variables.
144
     */
145
    #define CACHE_IGNORE_HEADERS_SET   1
146
    #define CACHE_IGNORE_HEADERS_UNSET 0
147
    unsigned int ignore_headers_set : 1;
137
} cache_server_conf;
148
} cache_server_conf;
138
149
139
/* cache info information */
150
/* cache info information */
Lines 257-263 CACHE_DECLARE(const char *)ap_cache_toks Link Here
257
/* Create a new table consisting of those elements from a request_rec's
268
/* Create a new table consisting of those elements from a request_rec's
258
 * headers_out that are allowed to be stored in a cache
269
 * headers_out that are allowed to be stored in a cache
259
 */
270
 */
260
CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool, apr_table_t *t);
271
CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_hdrs_out(apr_pool_t *pool, apr_table_t *t, server_rec *s);
261
272
262
/**
273
/**
263
 * cache_storage.c
274
 * cache_storage.c
(-)httpd-2.0.53.orig/modules/experimental/mod_disk_cache.c (-2 / +4 lines)
Lines 607-613 static apr_status_t store_headers(cache_ Link Here
607
        if (r->headers_out) {
607
        if (r->headers_out) {
608
            apr_table_t *headers_out;
608
            apr_table_t *headers_out;
609
609
610
            headers_out = ap_cache_cacheable_hdrs_out(r->pool, r->headers_out);
610
            headers_out = ap_cache_cacheable_hdrs_out(r->pool, r->headers_out,
611
                          r->server);
611
612
612
            if (!apr_table_get(headers_out, "Content-Type") &&
613
            if (!apr_table_get(headers_out, "Content-Type") &&
613
                r->content_type) {
614
                r->content_type) {
Lines 628-634 static apr_status_t store_headers(cache_ Link Here
628
        if (r->headers_in) {
629
        if (r->headers_in) {
629
            apr_table_t *headers_in;
630
            apr_table_t *headers_in;
630
631
631
            headers_in = ap_cache_cacheable_hdrs_out(r->pool, r->headers_in);
632
            headers_in = ap_cache_cacheable_hdrs_out(r->pool, r->headers_in,
633
                         r->server);
632
            rv = store_table(dobj->hfd, headers_in);
634
            rv = store_table(dobj->hfd, headers_in);
633
            if (rv != APR_SUCCESS) {
635
            if (rv != APR_SUCCESS) {
634
                return rv;
636
                return rv;
(-)httpd-2.0.53.orig/modules/experimental/mod_mem_cache.c (-2 / +4 lines)
Lines 745-757 static apr_status_t store_headers(cache_ Link Here
745
    /* Precompute how much storage we need to hold the headers */
745
    /* Precompute how much storage we need to hold the headers */
746
    rc = serialize_table(&mobj->header_out, 
746
    rc = serialize_table(&mobj->header_out, 
747
                         &mobj->num_header_out, 
747
                         &mobj->num_header_out, 
748
                         ap_cache_cacheable_hdrs_out(r->pool, r->headers_out));   
748
                         ap_cache_cacheable_hdrs_out(r->pool, r->headers_out,
749
                         r->server));   
749
    if (rc != APR_SUCCESS) {
750
    if (rc != APR_SUCCESS) {
750
        return rc;
751
        return rc;
751
    }
752
    }
752
    rc = serialize_table(&mobj->err_header_out, 
753
    rc = serialize_table(&mobj->err_header_out, 
753
                         &mobj->num_err_header_out, 
754
                         &mobj->num_err_header_out, 
754
                         ap_cache_cacheable_hdrs_out(r->pool, r->err_headers_out));   
755
                         ap_cache_cacheable_hdrs_out(r->pool, r->err_headers_out,
756
                         r->server));   
755
    if (rc != APR_SUCCESS) {
757
    if (rc != APR_SUCCESS) {
756
        return rc;
758
        return rc;
757
    }
759
    }

Return to bug 30399