Conversation
| map $cache_strategy $cache_header_cache_control { | ||
| "immutable" "max-age=31536000"; | ||
| "revalidate" "no-cache"; | ||
| "passthrough" ""; |
There was a problem hiding this comment.
I verified that if there's no value set for a header, that header isn't set by nginx.
There was a problem hiding this comment.
I see a PR to update nginx docs: "The add_header directive will not generate a header if the value provided is an empty string." except if it is multi-value header
| @@ -41,16 +44,19 @@ map "$request_method::$uri$is_args$args" $cache_strategy { | |||
| map $cache_strategy $cache_header_cache_control { | |||
| "immutable" "max-age=31536000"; | |||
There was a problem hiding this comment.
I think this should be public, max-age=31536000, immutable otherwise we don't know if intermediary caches will cache.
| @@ -41,16 +44,19 @@ map "$request_method::$uri$is_args$args" $cache_strategy { | |||
| map $cache_strategy $cache_header_cache_control { | |||
| "immutable" "max-age=31536000"; | |||
| "revalidate" "no-cache"; | |||
There was a problem hiding this comment.
Same as above, I think we can/should add public.
sadiqkhoja
left a comment
There was a problem hiding this comment.
Looks good to me. However, we should add one or two tests in test-nginx.js
| @@ -41,16 +44,19 @@ map "$request_method::$uri$is_args$args" $cache_strategy { | |||
| map $cache_strategy $cache_header_cache_control { | |||
| "immutable" "max-age=31536000"; | |||
|
@sadiqkhoja please verify the tests and either open a PR to fix or send me some comments if they're not right/complete! |
* Update assertions: Header object doesn't have headers as properties, we have to use .has() * Update mock-http-server to return cache headers for a sample API * Add test to assert that backend cache headers are passed through
* Update assertions: Header object doesn't have headers as properties, we have to use .has() * Update mock-http-server to return cache headers for a sample API * Add test to assert that backend cache headers are passed through
* Update assertions: Header object doesn't have headers as properties, we have to use .has() * Update mock-http-server to return cache headers for a sample API * Add test to assert that backend cache headers are passed through
* Update assertions: Header object doesn't have headers as properties, we have to use .has() * Update mock-http-server to return cache headers for a sample API * Add test to assert that backend cache headers are passed through
Closes #1048
What has been done to verify that this works as intended?
Put it on the dev server. Verified that there's exactly one
Cache-Controlheader and that it's set as expected.Why is this the best possible solution? Were any other approaches considered?
We could also set the headers here to
private, no-cache, etc. But then we'd be setting duplicate headers which could drift between nginx and backend. I think it's clearer to make caching headers clearly the backend's responsibility.Note that this does not set the
Pragmaheader for backend. I think we could do away with it altogether because it has been deprecated for a long time.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Backend responses should be cached in private caches. We should get 304s.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
nextbranch OR only changed documentation/infrastructure (masteris stable and used in production)