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

fix(proxy-cache): set Header Accept-Encoding as default values of vary_headers #12867

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions kong/plugins/proxy-cache/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ return {
elements = { type = "string" },
}},
{ vary_headers = { description = "Relevant headers considered for the cache key. If undefined, none of the headers are taken into consideration.", type = "array",
default = { "Accept-Encoding" },
Copy link
Member

@oowl oowl Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that have introduced breaking change. I am not sure if it is safe for our old version user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @dndx Can you help us to check it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review. Guess it shouldn't be regarded as a breaking change since it only affects how the cache key is calculated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't consider fixing a broken behavior a breaking change. ping @dndx

elements = { type = "string" },
}},
{ response_headers = {
Expand Down
7 changes: 7 additions & 0 deletions spec/03-plugins/31-proxy-cache/01-schema_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ describe("proxy-cache schema", function()
assert.is_truthy(entity)
end)

it("defines default vary_headers values", function()
local config = { strategy = "memory" }
local entity, err = v(config, proxy_cache_schema)
assert.is_nil(err)
assert.is_truthy(entity)
assert.same(entity.config.vary_headers, { "Accept-Encoding" })
end)
it("supports vary_headers values", function()
local entity, err = v({
strategy = "memory",
Expand Down
11 changes: 11 additions & 0 deletions spec/03-plugins/31-proxy-cache/03-api_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ describe("Plugin: proxy-cache", function()
assert.res_status(200, res)
assert.same("Miss", res.headers["X-Cache-Status"])
end)
it("miss if pass the Accept-Encoding", function()
local res = assert(proxy_client:get("/get", {
headers = {
host = "route-1.test",
["kong-debug"] = 1,
["Accept-Encoding"] = "gzip",
}
}))
assert.res_status(200, res)
assert.same("Miss", res.headers["X-Cache-Status"])
end)
git-hulk marked this conversation as resolved.
Show resolved Hide resolved
it("purge all the cache entries", function()
-- make a `Hit` request to `route-1`
local res = assert(proxy_client:get("/get", {
Expand Down