The author of this Squid-2 code was me, sponsored by Yahoo via Mark.

You also need the later bugfix limiting to 5xx responses. (author Mark)
http://www.squid-cache.org/Versions/v2/2.7/changesets/12391.patch

and CREDITS
http://www.squid-cache.org/Versions/v2/2.7/changesets/11798.patch

All the squid-2 changesets related to stale-if-error and
stale-while-revalidate can be found with the 11797 tag at
http://www.squid-cache.org/Versions/v2/2.7/changesets/merge.html

Regards
Henrik


mån 2010-12-27 klockan 01:37 +1300 skrev Amos Jeffries:
> ------------------------------------------------------------
> revno: 11141
> fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=2255
> committer: Amos Jeffries <[email protected]>
> branch nick: trunk
> timestamp: Mon 2010-12-27 01:37:51 +1300
> message:
>   Author: Mark Nottingham <[email protected]>
>   Support RFC 5861 Cache-Control: stale-if-error option          
>   
>   The default behaviour for Squid is to present the stale object when
>   revalidation fails with a 5xx error.
>   
>   stale-if-error places a maximum limit on how long this stale object may
>   be sent. After the limit has passed Squid is required to present the 5xx
>   message to the client.                                         
>   
>   Original code for Squid-2 was sponsored by Yahoo!.
>   
>   Portage done by Alex Rousskov and Amos Jeffries.
> modified:
>   src/HttpHdrCc.cc
>   src/enums.h
>   src/refresh.cc
>   src/structs.h
> vanligt textdokument-bilaga (r11141.diff)
> === modified file 'src/HttpHdrCc.cc'
> --- a/src/HttpHdrCc.cc        2010-10-04 15:32:20 +0000
> +++ b/src/HttpHdrCc.cc        2010-12-26 12:37:51 +0000
> @@ -51,6 +51,7 @@
>      {"max-age", (http_hdr_type)CC_MAX_AGE},
>      {"s-maxage", (http_hdr_type)CC_S_MAXAGE},
>      {"max-stale", (http_hdr_type)CC_MAX_STALE},
> +    {"stale-if-error", (http_hdr_type)CC_STALE_IF_ERROR},
>      {"min-fresh", (http_hdr_type)CC_MIN_FRESH},
>      {"Other,", (http_hdr_type)CC_OTHER}      /* ',' will protect from 
> matches */
>  };
> @@ -192,6 +193,14 @@
>  
>              break;
>  
> +       case CC_STALE_IF_ERROR:
> +           if (!p || !httpHeaderParseInt(p, &cc->stale_if_error)) {
> +               debugs(65, 2, "cc: invalid stale-if-error specs near '" << 
> item << "'");
> +               cc->stale_if_error = -1;
> +               EBIT_CLR(cc->mask, type);
> +           }
> +           break;
> +
>          case CC_OTHER:
>  
>              if (cc->other.size())
> 
> === modified file 'src/enums.h'
> --- a/src/enums.h     2010-12-12 05:30:58 +0000
> +++ b/src/enums.h     2010-12-26 12:37:51 +0000
> @@ -100,6 +100,7 @@
>      CC_MAX_STALE,
>      CC_MIN_FRESH,
>      CC_ONLY_IF_CACHED,
> +    CC_STALE_IF_ERROR,
>      CC_OTHER,
>      CC_ENUM_END
>  } http_hdr_cc_type;
> 
> === modified file 'src/refresh.cc'
> --- a/src/refresh.cc  2010-11-03 16:10:13 +0000
> +++ b/src/refresh.cc  2010-12-26 12:37:51 +0000
> @@ -283,6 +283,15 @@
>  
>      debugs(22, 3, "Staleness = " << staleness);
>  
> +    // stale-if-error requires any failure be passed thru when its period is 
> over.
> +    if (request && entry->mem_obj && entry->mem_obj->getReply() && 
> entry->mem_obj->getReply()->cache_control &&
> +            EBIT_TEST(entry->mem_obj->getReply()->cache_control->mask, 
> CC_STALE_IF_ERROR) &&
> +            entry->mem_obj->getReply()->cache_control->stale_if_error < 
> staleness) {
> +
> +        debugs(22, 3, "refreshCheck: stale-if-error period expired.");
> +        request->flags.fail_on_validation_err = 1;
> +    }
> +
>      if (EBIT_TEST(entry->flags, ENTRY_REVALIDATE) && staleness > -1
>  #if USE_HTTP_VIOLATIONS
>              && !R->flags.ignore_must_revalidate
> 
> === modified file 'src/structs.h'
> --- a/src/structs.h   2010-12-15 09:38:03 +0000
> +++ b/src/structs.h   2010-12-26 12:37:51 +0000
> @@ -714,6 +714,7 @@
>      int max_age;
>      int s_maxage;
>      int max_stale;
> +    int stale_if_error;
>      int min_fresh;
>      String other;
>  };
> 


Reply via email to