-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Headers can't be added by matching against response matchers #6763
Comments
You can use |
Thanks, that helps a lot! Is there a limitation preventing |
I'm not sure what you mean. They do completely different things. The The They have completely different responsibilities. |
Thanks for the reply. I should clarify, what I meant to ask was, could For example, the following json configuration matches 2xx responses: {
"handler": "headers",
"response": {
"require": {
"status_code": [
2
]
},
"set": {
"Cache-Control": [
"public, max-age=3600"
]
}
}
},
|
Caddyfile:
Error:
Since Chrome caches 404 responses, I want to add the
Cache-Control
response header only when the response status is ok (2xx).I looked at Response Matchers (Caddyfile) -- Caddy documentation, which documents the response matcher above, and combined that with the
header
directive as documented in header (Caddyfile directive) -- Caddy documentation, but counterintuitively,header
can only use request matchers.encode (Caddyfile directive) -- Caddy documentation leads to believe that response matchers can only be used in specific places, not in a named matcher (is the response matcher example out of date?). However, since both the
header
directive and theencode
directive act on pre-existing responses, it's natural that both can match using response matchers, not justencode
.A caddy community help post (Header only on successful response) suggests a workaround using
php_fastcgi
. However, that makes the Caddyfile unreadable and opaque since my application really has nothing to do with PHP.The text was updated successfully, but these errors were encountered: