Rainer Canavan
unread,Jul 5, 2022, 9:56:44 AM7/5/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openre...@googlegroups.com
Hi,
We are using openresty as a reverse proxy, and with 1.17.8.2, we used
to remove a query argument from requests to improve the cache hit rate
of the varnish that sits between openresty and the slow source server.
The code we used in access_by_lua was the following:
if (string.match(ngx.var.uri, '^/cms/')) then
if ngx.var.QUERY_STRING then
local args = ngx.req.get_uri_args()
if args.click ~= nil then
args.click = "removed"
ngx.req.set_uri_args(args)
end
end
end
That used to work splendidly, with respectable cache hit rates way
above 90%. After an upgrade to openresty 1.19.9.1, the cache hit rate
has dropped dramatically, since ngx.req.set_uri_args() fills the
arguments in a non-stable, essentially random order into ngx.var.args,
even for multiple, sequential requests that are identical.
As a workaround, we're simply using ngx.re.gsub(ngx.var.args, ...),
but the old solution is more elegant in my opinon. We've tried
multiple ways to re-sort the args table before passing it to
ngx.req.set_uri_args() without any observable change in behavior. Is
there any way to make ngx.req.set_uri_args() produce predictable
$ngs.var.args?
Rainer
--
Rainer Canavan