Add support for stale-if-error Cache-Control directive
Originally PR #13.
Useful for Squid and other proxies to allow stale content to be served if the server has an error:
The stale-if-error HTTP Cache-Control extension improves availability of some kinds of cached content by allowing servers and clients to instruct caches to use stale responses when certain error conditions are encountered.
Thanks! I have two suggestions on this:
-
The new configurable comment says "If not zero, will set stale-if-error extension for Cache-Control (e.g. for Squid)", which is a mismatch with the actual check: ( $this->stale_if_error > 0 ); We should probably take a true/false approach.
-
In order to make it cleaner and reduce code duplication, I propose that we use a add_cache_control_headers() function, which: a) Returns if $this->cache_control is not enabled. b) Returns if Last-Modified / Cache-Control headers are already set. c) Appends to $this->headers otherwise, which will afterwards be sent by do_headers()