From cbe3a7194d6bafb5030b94fbad71f0e70fd499fe Mon Sep 17 00:00:00 2001 From: wessels <> Date: Fri, 21 Aug 1998 04:45:44 +0000 Subject: [PATCH] Henrik's refresh_pattern reload patch --- src/cache_cf.cc | 28 ++++++++++++++++++++++------ src/cf.data.pre | 24 +++++++++++++++++++----- src/client_side.cc | 43 ++++++++++++++++++++++++++----------------- src/enums.h | 4 ++-- src/globals.h | 3 ++- src/refresh.cc | 29 +++++++++++++++++++++++------ src/structs.h | 6 +++++- 7 files changed, 99 insertions(+), 38 deletions(-) diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 09f3303ab0..ff4213320a 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.299 1998/08/20 02:49:10 wessels Exp $ + * $Id: cache_cf.cc,v 1.300 1998/08/20 22:45:44 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -1115,15 +1115,17 @@ static void dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) { while (head != NULL) { - storeAppendPrintf(entry, "%s%s %s %d %d%% %d%s%s\n", + storeAppendPrintf(entry, "%s%s %s %d %d%% %d%s%s%s%s\n", name, head->flags.icase ? " -i" : null_string, head->pattern, (int) head->min / 60, (int) (100.0 * head->pct + 0.5), (int) head->max / 60, - head->flags.override_expire ? " override_expire" : null_string, - head->flags.override_lastmod ? " override_lastmod" : null_string); + head->flags.override_expire ? " override-expire" : null_string, + head->flags.override_lastmod ? " override-lastmod" : null_string, + head->flags.reload_into_ims ? " reload-into-ims" : null_string, + head->flags.ignore_reload ? " ignore-reload" : null_string); head = head->next; } } @@ -1138,6 +1140,8 @@ parse_refreshpattern(refresh_t ** head) time_t max = 0; int override_expire = 0; int override_lastmod = 0; + int reload_into_ims = 0; + int ignore_reload = 0; int i; refresh_t *t; regex_t comp; @@ -1167,8 +1171,16 @@ parse_refreshpattern(refresh_t ** head) override_expire = 1; else if (!strcmp(token, "override-expire")) override_lastmod = 1; - else - debug(22, 0) ("redreshAddToLost: Unknown option '%s': %s\n", + else if (!strcmp(token, "reload-into-ims")) { + reload_into_ims = 1; + refresh_nocache_hack = 1; + /* tell client_side.c that this is used */ + } else if (!strcmp(token, "ignore-reload")) { + ignore_reload = 1; + refresh_nocache_hack = 1; + /* tell client_side.c that this is used */ + } else + debug(22, 0) ("redreshAddToList: Unknown option '%s': %s\n", pattern, token); } if ((errcode = regcomp(&comp, pattern, flags)) != 0) { @@ -1194,6 +1206,10 @@ parse_refreshpattern(refresh_t ** head) t->flags.override_expire = 1; if (override_lastmod) t->flags.override_lastmod = 1; + if (reload_into_ims) + t->flags.reload_into_ims = 1; + if (ignore_reload) + t->flags.ignore_reload = 1; t->next = NULL; while (*head) head = &(*head)->next; diff --git a/src/cf.data.pre b/src/cf.data.pre index 26fcb225c5..ee475fe563 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.98 1998/08/17 23:27:59 wessels Exp $ +# $Id: cf.data.pre,v 1.99 1998/08/20 22:45:45 wessels Exp $ # # # SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1008,15 +1008,26 @@ DOC_START options: override-expire override-lastmod + reload-into-ims + ignore-reload override-expire enforces min age even if the server - sent a Expires: header. Warning: This breaks HTTP - freshness control, and may have servere inpact on - the usability of sites that makes correct use of - Expires: headers on dynamic data. + sent a Expires: header. Doing this VIOLATES the HTTP + standard. Enabling this feature could make you liable + for problems which it causes. override-lastmod enforces min age even on objects that was modified recently. + + reload-into-ims changes client no-cache or ``reload'' + to If-Modified-Since requests. Doing this VIOLATES the + HTTP standard. Enabling this feature could make you + liable for problems which it causes. + + ignore-reload ignores a client no-cache or ``reload'' + header. Doing this VIOLATES the HTTP standard. Enabling + this feature could make you liable for problems which + it causes. Please see the file doc/Release-Notes-1.1.txt for a full description of Squid's refresh algorithm. Basically a @@ -2040,6 +2051,9 @@ DOC_START Doing this VIOLATES the HTTP standard. Enabling this feature could make you liable for problems which it causes. + + see also refresh_pattern for a more selective approach. + reload_into_ims off DOC_END diff --git a/src/client_side.cc b/src/client_side.cc index 0ef3017910..aeb44803fc 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.383 1998/08/19 23:07:23 wessels Exp $ + * $Id: client_side.cc,v 1.384 1998/08/20 22:45:46 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -680,10 +680,12 @@ clientInterpretRequestHeaders(clientHttpRequest * http) if (httpHeaderHas(req_hdr, HDR_PRAGMA)) { String s = httpHeaderGetList(req_hdr, HDR_PRAGMA); if (strListIsMember(&s, "no-cache", ',')) { - if (!Config.onoff.reload_into_ims) - EBIT_SET(request->flags, REQ_NOCACHE); + if (Config.onoff.reload_into_ims) + EBIT_SET(request->flags, REQ_NOCACHE_HACK); + else if (refresh_nocache_hack) + EBIT_SET(request->flags, REQ_NOCACHE_HACK); else - EBIT_SET(request->flags, REQ_NOCACHE_IMS); + EBIT_SET(request->flags, REQ_NOCACHE); } stringClean(&s); } @@ -1143,10 +1145,25 @@ clientCacheHit(void *data, char *buf, ssize_t size) */ http->log_type = LOG_TCP_MISS; clientProcessMiss(http); + } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) { + /* + * This did not match a refresh pattern that overrides no-cache + * we should honour the client no-cache header. + */ + http->log_type = LOG_TCP_CLIENT_REFRESH_MISS; + clientProcessMiss(http); } else if (r->protocol == PROTO_HTTP) { + /* + * Object needs to be revalidated + * XXX This could apply to FTP as well, if Last-Modified is known. + */ http->log_type = LOG_TCP_REFRESH_MISS; clientProcessExpired(http); } else { + /* + * We don't know how to re-validate other protocols. Handle + * them as if the object has expired. + */ http->log_type = LOG_TCP_MISS; clientProcessMiss(http); } @@ -1577,27 +1594,19 @@ clientProcessRequest2(clientHttpRequest * http) /* this object isn't in the cache */ return LOG_TCP_MISS; } else if (!storeEntryValidToSend(e)) { - storeRelease(e); http->entry = NULL; return LOG_TCP_MISS; } else if (EBIT_TEST(e->flag, ENTRY_SPECIAL)) { /* Special entries are always hits, no matter what the client says */ http->entry = e; return LOG_TCP_HIT; - } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) { - /* NOCACHE should always eject a negative cached object */ - if (EBIT_TEST(e->flag, ENTRY_NEGCACHED)) - storeRelease(e); - /* NOCACHE+IMS should not eject a valid object */ - else if (EBIT_TEST(r->flags, REQ_IMS)) - (void) 0; - /* Request-Range should not eject a valid object */ - else if (EBIT_TEST(r->flags, REQ_RANGE)) - (void) 0; - else - storeRelease(e); + } else if (EBIT_TEST(r->flags, REQ_NOCACHE_HACK)) { + http->entry = NULL; ipcacheReleaseInvalid(r->host); + return LOG_TCP_CLIENT_REFRESH_MISS; + } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) { http->entry = NULL; + ipcacheReleaseInvalid(r->host); return LOG_TCP_CLIENT_REFRESH_MISS; } else { http->entry = e; diff --git a/src/enums.h b/src/enums.h index d07b3e893b..32b8329976 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.120 1998/08/20 22:29:58 wessels Exp $ + * $Id: enums.h,v 1.121 1998/08/20 22:45:47 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -480,7 +480,7 @@ enum { REQ_REFRESH, REQ_USED_PROXY_AUTH, REQ_REDIRECTED, - REQ_NOCACHE_IMS /* for changing no-cache requests into IMS */ + REQ_NOCACHE_HACK /* for changing/ignoring no-cache requests */ }; enum { diff --git a/src/globals.h b/src/globals.h index 1d940f669c..317c8e73fb 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.63 1998/07/31 00:15:44 wessels Exp $ + * $Id: globals.h,v 1.64 1998/08/20 22:45:48 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -138,3 +138,4 @@ extern icpUdpData *IcpQueueHead; /* NULL */ #if DELAY_POOLS extern time_t delay_pools_last_update; /* 0 */ #endif +extern int refresh_nocache_hack; /* 0 */ diff --git a/src/refresh.cc b/src/refresh.cc index c616ec49c5..addda2729c 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -1,6 +1,7 @@ + /* - * $Id: refresh.cc,v 1.31 1998/08/17 21:27:32 wessels Exp $ + * $Id: refresh.cc,v 1.32 1998/08/20 22:45:49 wessels Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -102,6 +103,8 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta) time_t max = REFRESH_DEFAULT_MAX; int override_expire = 0; int override_lastmod = 0; + int reload_into_ims = 0; + int ignore_reload = 0; const char *pattern = "."; time_t age; double factor; @@ -117,11 +120,6 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta) refreshCounts.revalidate_stale++; return 1; } - if (EBIT_TEST(request->flags, REQ_NOCACHE_IMS)) { - debug(22, 3) ("refreshCheck: YES: Reload into IMS\n"); - refreshCounts.revalidate_stale++; - return 1; - } if ((R = refreshLimits(uri))) { min = R->min; pct = R->pct; @@ -129,13 +127,32 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta) pattern = R->pattern; override_expire = R->flags.override_expire; override_lastmod = R->flags.override_lastmod; + reload_into_ims = R->flags.reload_into_ims; + ignore_reload = R->flags.ignore_reload; } + if (!reload_into_ims) + reload_into_ims = Config.onoff.reload_into_ims; debug(22, 3) ("refreshCheck: Matched '%s %d %d%% %d'\n", pattern, (int) min, (int) (100.0 * pct), (int) max); age = check_time - entry->timestamp; debug(22, 3) ("refreshCheck: age = %d\n", (int) age); debug(22, 3) ("\tcheck_time:\t%s\n", mkrfc1123(check_time)); debug(22, 3) ("\tentry->timestamp:\t%s\n", mkrfc1123(entry->timestamp)); + if (EBIT_TEST(request->flags, REQ_NOCACHE_HACK)) { + if (ignore_reload) { + /* The clients no-cache header is ignored */ + debug(22, 3) ("refreshCheck: MAYBE: ignore-reload\n"); + } else if (reload_into_ims) { + /* The clients no-cache header is changed into a IMS query */ + debug(22, 3) ("refreshCheck: YES: reload-into-ims\n"); + return 1; + } else { + /* The clients no-cache header is not overridden on this request */ + debug(22, 3) ("refreshCheck: YES: client reload\n"); + EBIT_SET(request->flags, REQ_NOCACHE); + return 1; + } + } if (request->max_age > -1) { if (age > request->max_age) { debug(22, 3) ("refreshCheck: YES: age > client-max-age\n"); diff --git a/src/structs.h b/src/structs.h index 3361dcb85a..41eae7fc48 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.206 1998/08/19 23:10:30 wessels Exp $ + * $Id: structs.h,v 1.207 1998/08/20 22:45:50 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -79,9 +79,11 @@ struct _acl_deny_info_list { }; #if USE_ARP_ACL + struct _acl_arp_data { char eth[6]; }; + #endif struct _String { @@ -1228,6 +1230,8 @@ struct _refresh_t { unsigned int icase:1; unsigned int override_expire:1; unsigned int override_lastmod:1; + unsigned int reload_into_ims:1; + unsigned int ignore_reload:1; } flags; }; -- 2.47.3