-
-
Notifications
You must be signed in to change notification settings - Fork 607
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 X-Cache-Enabled
HTTP header
#1513
base: master
Are you sure you want to change the base?
Conversation
If possible (and relatively easy) I might prefer this just to avoid having "duplicate" response headers. In the long run it might be better to unify on the more generic 🤔 Another reason to try and limit this to loopback if possible. |
@swalkinshaw: Ideally the Yes, constraining the header to loopback requests only would be a good idea, it should be relatively easy using the map. |
@swalkinshaw: Alternative proposal: Add the Related WordPress trac issue (alternative/improved methods of detecting page cache): https://core.trac.wordpress.org/ticket/57349 |
We definitely won't add this in Bedrock by default. I'm not against supporting it in Trellis if we can limit to loopback. I think |
Side note: The already added |
After some experimentation I noticed that WordPress does not check for the upstream HTTP header, but rather does a loopback HTTP request and checks the HTTP headers from it. So the cache-specific header must be added to the reverse proxy frontend, it could still be added conditionally, for those WordPress loopback requests only, but this would not work as an added upstream HTTP header. |
…equests. Move `X-Cache-Enabled` HTTP header to PHP-specific `location` block.
@swalkinshaw: It was not as trivial as I thought first, but now the configuration only adds the |
…avoid clearing all `location` headers.
This PR adds the
X-Cache-Enabled
HTTP header tonginx
responses. It will not be added when upstream cache status isBYPASS
as then no caching is used for the request.WordPress Site Health Page Caching uses specific HTTP header values in the loopback HTTP response in order to detect that page caching is indeed enabled.
The related
Fastcgi-Cache
HTTP header is added by Trellis, but not used by the WordPress site health check.Adding this to Trellis by default appears to be a good idea (no obvious side-effects, improving compatibility with WordPress core (site health check)).
See roots discussion: https://discourse.roots.io/t/site-health-check-page-cache-not-detected/25640/2
Note: Should this
X-Cache-Enabled
HTTP header only be added to loopback requests? On the other hand, theFastcgi-Cache
HTTP header is also already added to all requests.Possible alternative: A Bedrock MU plugin that uses the
Fastcgi-Cache
HTTP header to setX-Cache-Enabled
in PHP code.