From 799c13b47ca6d444eb07fec3b82970a318e30a00 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 15 May 2009 18:38:46 +1200 Subject: [PATCH] Author: Mark Nottingham Bug 2645: allow squid to ignore must-revalidate --- doc/release-notes/release-3.1.sgml | 9 ++++++++- src/cache_cf.cc | 16 ++++++++++++++++ src/cf.data.pre | 6 ++++++ src/refresh.cc | 6 +++++- src/structs.h | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/doc/release-notes/release-3.1.sgml b/doc/release-notes/release-3.1.sgml index dce25cba7b..af8a770b32 100644 --- a/doc/release-notes/release-3.1.sgml +++ b/doc/release-notes/release-3.1.sgml @@ -958,7 +958,14 @@ NOCOMMENT_START

Changing this is an RFC 2616 violation and now requires --enable-http-violations refresh_pattern -

New set of basic patterns. These should always be listed after any custom ptterns. +

New option 'ignore-must-revalidate'. + + ignore-must-revalidate ignores any ``Cache-Control: must-revalidate`` + headers received from a server. Doing this VIOLATES + the HTTP standard. Enabling this feature could make you + liable for problems which it causes. + +

New set of basic patterns. These should always be listed after any custom patterns. They ensure RFC compliance with certain protocol and request handling in the absence of accurate Cache-Control: and Expires: information. diff --git a/src/cache_cf.cc b/src/cache_cf.cc index b2c60bb37c..7db3150dfc 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -582,6 +582,13 @@ configDoConfigure(void) break; } + for (R = Config.Refresh; R; R = R->next) { + if (!R->flags.ignore_must_revalidate) + continue; + debugs(22, 1, "WARNING: use of 'ignore-must-revalidate' in 'refresh_pattern' violates HTTP"); + break; + } + for (R = Config.Refresh; R; R = R->next) { if (!R->flags.ignore_private) continue; @@ -2211,6 +2218,9 @@ dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) if (head->flags.ignore_no_store) storeAppendPrintf(entry, " ignore-no-store"); + if (head->flags.ignore_must_revalidate) + storeAppendPrintf(entry, " ignore-must-revalidate"); + if (head->flags.ignore_private) storeAppendPrintf(entry, " ignore-private"); @@ -2242,6 +2252,7 @@ parse_refreshpattern(refresh_t ** head) int ignore_reload = 0; int ignore_no_cache = 0; int ignore_no_store = 0; + int ignore_must_revalidate = 0; int ignore_private = 0; int ignore_auth = 0; #endif @@ -2298,6 +2309,8 @@ parse_refreshpattern(refresh_t ** head) ignore_no_cache = 1; else if (!strcmp(token, "ignore-no-store")) ignore_no_store = 1; + else if (!strcmp(token, "ignore-must-revalidate")) + ignore_must_revalidate = 1; else if (!strcmp(token, "ignore-private")) ignore_private = 1; else if (!strcmp(token, "ignore-auth")) @@ -2359,6 +2372,9 @@ parse_refreshpattern(refresh_t ** head) if (ignore_no_store) t->flags.ignore_no_store = 1; + if (ignore_must_revalidate) + t->flags.ignore_must_revalidate = 1; + if (ignore_private) t->flags.ignore_private = 1; diff --git a/src/cf.data.pre b/src/cf.data.pre index 605bdd8306..e7e53807bf 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -2904,6 +2904,7 @@ DOC_START ignore-reload ignore-no-cache ignore-no-store + ignore-must-revalidate ignore-private ignore-auth refresh-ims @@ -2938,6 +2939,11 @@ DOC_START the HTTP standard. Enabling this feature could make you liable for problems which it causes. + ignore-must-revalidate ignores any ``Cache-Control: must-revalidate`` + headers received from a server. Doing this VIOLATES + the HTTP standard. Enabling this feature could make you + liable for problems which it causes. + ignore-private ignores any ``Cache-control: private'' headers received from a server. Doing this VIOLATES the HTTP standard. Enabling this feature could make you diff --git a/src/refresh.cc b/src/refresh.cc index 05ea670cac..90de81ef26 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -271,7 +271,11 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) debugs(22, 3, "\tentry->timestamp:\t" << mkrfc1123(entry->timestamp)); - if (EBIT_TEST(entry->flags, ENTRY_REVALIDATE) && staleness > -1) { + if (EBIT_TEST(entry->flags, ENTRY_REVALIDATE) && staleness > -1 +#if HTTP_VIOLATIONS + && !R->flags.ignore_must_revalidate +#endif + ) { debugs(22, 3, "refreshCheck: YES: Must revalidate stale response"); return STALE_MUST_REVALIDATE; } diff --git a/src/structs.h b/src/structs.h index e83b11b74c..8065a509c1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1086,6 +1086,7 @@ struct _refresh_t { unsigned int ignore_reload:1; unsigned int ignore_no_cache:1; unsigned int ignore_no_store:1; + unsigned int ignore_must_revalidate:1; unsigned int ignore_private:1; unsigned int ignore_auth:1; #endif -- 2.47.3