Bug 31030 - mod_cache does not seem to process CacheIgnoreCacheControl correctly
Summary: mod_cache does not seem to process CacheIgnoreCacheControl correctly
Status: CLOSED WONTFIX
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cache (show other bugs)
Version: 2.0.50
Hardware: Sun other
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2004-09-03 05:49 UTC by Manish Dubey
Modified: 2009-05-22 08:10 UTC (History)
0 users



Attachments
mod_cache.c diffs (439 bytes, patch)
2004-09-03 19:16 UTC, Manish Dubey
Details | Diff
mod_cache.h diffs (601 bytes, patch)
2004-09-03 19:17 UTC, Manish Dubey
Details | Diff
cache_util.c diffs (1.22 KB, patch)
2004-09-03 19:17 UTC, Manish Dubey
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manish Dubey 2004-09-03 05:49:18 UTC
mod_cache is enabled with mod_jk in this scenario. Not sure if it is a problem with other modules
too (ex. mod_proxy). This exists in cvs-head version (as of 08/31/2004) of mod*cache code.

Configuration:

LogLevel debug

<IfModule mod_cache.c>
    <IfModule mod_disk_cache.c>
        CacheRoot /tmp/cacheroot
        CacheIgnoreCacheControl On
        CacheSize 256
        CacheEnable disk /UIServlet/cache
        CacheDirLevels 5
        CacheDirLength 3
    </IfModule>
</IfModule>

JkMount /UIServlet/*    test
JkWorkersFile /tmp/apache2/conf/mojk.properties

Hitting the URL like:

http://servername/UIServlet/cache/Logo.gif

For the first time return the correct response with the following in the log. The cache look ok
on disk.

[Thu Sep 02 17:04:33 2004] [debug] mod_cache.c(114): incoming request is asking
for a uncached version of /UIServlet/cache/Logo.gif,
 but we know better and are ignoring it
[Thu Sep 02 17:04:33 2004] [info] disk_cache: Storing URL vela/UIServlet/cache/a
riba/resource/en_US/images/Logo.gif?
[Thu Sep 02 17:04:33 2004] [debug] mod_cache.c(615): cache: Caching url: /UIServ
let/cache/Logo.gif
[Thu Sep 02 17:04:33 2004] [debug] mod_disk_cache.c(622): disk_cache: Stored hea
ders for URL vela/UIServlet/cache/Logo.gif?
[Thu Sep 02 17:04:33 2004] [debug] mod_headers.c(511): headers: ap_headers_outpu
t_filter()
[Thu Sep 02 17:04:33 2004] [debug] mod_disk_cache.c(693): disk_cache: Body for U
RL vela/UIServlet/cache/Logo.gif? cached.


Hitting it again, browser (firefox and camino) make following request:

Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Thu, 08 Jul 2004 20:16:07 GMT
Cache-Control: max-age=0

This results in content to be refetched from the tomcat server (although CacheIgnoreCacheControl is
On) The resulting log looks like:

[Thu Sep 02 17:04:39 2004] [debug] mod_cache.c(114): incoming request is asking
for a uncached version of /UIServlet/cache/Logo.gif,
 but we know better and are ignoring it
[Thu Sep 02 17:04:39 2004] [debug] mod_disk_cache.c(400): disk_cache: Recalled c
ached URL info header vela/UIServlet/cache/Logo.gif?
[Thu Sep 02 17:04:39 2004] [debug] mod_disk_cache.c(464): disk_cache: Recalled h
eaders for URL vela/UIServlet/cache/Logo.gif?
[Thu Sep 02 17:04:39 2004] [debug] mod_cache.c(256): cache: running CACHE_OUT fi
lter
[Thu Sep 02 17:04:39 2004] [debug] mod_cache.c(265): cache: serving /UIServlet/c
ache/Logo.gif
[Thu Sep 02 17:04:47 2004] [debug] mod_cache.c(114): incoming request is asking
for a uncached version of /UIServlet/cache/Logo.gif,
 but we know better and are ignoring it
[Thu Sep 02 17:04:47 2004] [debug] mod_disk_cache.c(400): disk_cache: Recalled c
ached URL info header vela/UIServlet/cache/Logo.gif?
[Thu Sep 02 17:04:47 2004] [debug] mod_disk_cache.c(464): disk_cache: Recalled h
eaders for URL vela/UIServlet/cache/Logo.gif?
[Thu Sep 02 17:04:47 2004] [debug] mod_cache.c(285): cache: running CACHE_CONDIT
IONAL filter
[Thu Sep 02 17:04:47 2004] [debug] mod_headers.c(511): headers: ap_headers_outpu
t_filter()
[Thu Sep 02 17:04:47 2004] [info] disk_cache: Storing URL vela/UIServlet/cache/a
riba/resource/en_US/images/Logo.gif?
[Thu Sep 02 17:04:47 2004] [debug] mod_cache.c(615): cache: Caching url: /UIServ
let/cache/Logo.gif
[Thu Sep 02 17:04:47 2004] [debug] mod_disk_cache.c(622): disk_cache: Stored hea
ders for URL vela/UIServlet/cache/Logo.gif?
[Thu Sep 02 17:04:47 2004] [debug] mod_disk_cache.c(685): cache_disk: URL vela/U
IServlet/cache/Logo.gif? failed the size check (0<1)

Looking through the code seems like altough mod_cache.c looks at this setting, it is not
passed along to ap_cache_check_freshness() (in cache_util.c).

I have attempted to fix this, not sure if this is how it should be fixed. Diffs included here. I
tested this with both IgnoreCacheControl flag On and Off (with IE, Firefox, Camino and Safari)
and it seems to work.

Diffs:

--- orig/mod_cache.h    2004-09-02 22:06:23.419972000 -0700
+++ ./mod_cache.h       2004-09-02 19:19:12.848806000 -0700
@@ -234,7 +234,9 @@
  * @param r request_rec
  * @return 0 ==> cache object is stale, 1 ==> cache object is fresh
  */
-CACHE_DECLARE(int) ap_cache_check_freshness(cache_request_rec *cache, request_rec *r);
+
+/*XXXX: Ariba */
+CACHE_DECLARE(int) ap_cache_check_freshness(cache_request_rec *cache, request_rec *r, int 
ignorecachecontrol);
 CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x);
 CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
 CACHE_DECLARE(char *) generate_name(apr_pool_t *p, int dirlevels, 


--- orig/cache_util.c   2004-09-02 22:06:35.678215000 -0700
+++ ./cache_util.c      2004-09-02 19:24:23.933579000 -0700
@@ -118,13 +118,17 @@
     return apr_time_sec(current_age);
 }
 
CACHE_DECLARE(int) ap_cache_check_freshness(cache_request_rec *cache, 
-                                            request_rec *r)
+                                            request_rec *r,
+                                           int ignorecachecontrol)
 {
     apr_int64_t age, maxage_req, maxage_cresp, maxage, smaxage, maxstale;
     apr_int64_t minfresh;
     int age_in_errhdr = 0;
-    const char *cc_cresp, *cc_ceresp, *cc_req;
+    const char *cc_cresp = NULL;
+    const char *cc_ceresp = NULL;
+    const char *cc_req = NULL;
     const char *agestr = NULL;
     const char *expstr = NULL;
     char *val;
@@ -163,9 +167,13 @@
      * entity, and it's value is in the past, it has expired.
      * 
      */
+
+   if (!ignorecachecontrol) {
        cc_cresp = apr_table_get(r->headers_out, "Cache-Control");
        cc_ceresp = apr_table_get(r->err_headers_out, "Cache-Control");
        cc_req = apr_table_get(r->headers_in, "Cache-Control");
+   }
     
     if ((agestr = apr_table_get(r->headers_out, "Age"))) {
         age_c = apr_atoi64(agestr);



--- orig/mod_cache.c    2004-09-02 22:06:14.785339000 -0700
+++ ./mod_cache.c       2004-09-02 19:17:48.701744000 -0700
@@ -160,7 +160,7 @@
     /* We have located a suitable cache file now. */
 
     /* RFC2616 13.2 - Check cache object expiration */
-    cache->fresh = ap_cache_check_freshness(cache, r);
+    cache->fresh = ap_cache_check_freshness(cache, r, conf->ignorecachecontrol);
 
     /* What we have in our cache isn't fresh. */
     if (!cache->fresh) {
Comment 1 Manish Dubey 2004-09-03 19:16:43 UTC
Created attachment 12640 [details]
mod_cache.c diffs
Comment 2 Manish Dubey 2004-09-03 19:17:13 UTC
Created attachment 12641 [details]
mod_cache.h diffs
Comment 3 Manish Dubey 2004-09-03 19:17:33 UTC
Created attachment 12642 [details]
cache_util.c diffs
Comment 4 Manish Dubey 2004-09-03 19:19:15 UTC
Reworked changes to not ignore Cache-Control in response headers, only ignore it in request header.
diffs attched above.
Comment 5 Dan Poirier 2009-05-22 07:49:06 UTC
Seems reasonable, but in over 4 years no one has considered it important enough to fix.  Closing for now; can be reopened if the issue comes up again.