batcache icon indicating copy to clipboard operation
batcache copied to clipboard

Add support for stale-if-error Cache-Control directive

Open westonruter opened this issue 10 years ago • 1 comments

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.

See The stale-if-error HTTP Cache-Control Extension.

westonruter avatar Oct 21 '15 18:10 westonruter

Thanks! I have two suggestions on this:

  1. 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.

  2. 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()

vnsavage avatar Oct 22 '15 07:10 vnsavage