Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

westonruter
Copy link
Contributor

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.

@vnsavage
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants