You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2004/09/03 07:49:19 UTC

DO NOT REPLY [Bug 31030] New: - mod_cache does not seem to process CacheIgnoreCacheControl correctly

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31030>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31030

mod_cache does not seem to process CacheIgnoreCacheControl correctly

           Summary: mod_cache does not seem to process
                    CacheIgnoreCacheControl correctly
           Product: Apache httpd-2.0
           Version: 2.0.50
          Platform: Sun
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: mod_cache
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: mdubey@ariba.com


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) {

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org