help needed : catch a url and use in a location block

Francis Daly francis at daoine.org
Tue Jan 8 20:25:58 UTC 2019


On Tue, Jan 08, 2019 at 01:47:39PM +0300, ender ulusoy wrote:

Hi there,

> An example URL is here:
> 
> https://www.example.com/campains/a4/search?page=1&criteria%5Badv_id%5D=2004
> 
> I won't use cache on other pages. And I don't want to use an if condition
> because this page gets high traffic. How can I achieve that? What will be
> the right regex to catch this URL as a location block?

A "location" match does not involve the query string -- that is, it
stops looking before the ?. So no "location" block can match adv_id in
the query string.

You could do something like

  if ($args ~ "adv_id") {}

to set a variable, and then later cache (or not) based on that variable.

But if you don't like "if", you'll want to come up with another way of
doing something similar. Perhaps "map"?

Does adv_id ever appear outside of the query string, where a "location"
could match it? If so, you may want to use $request_uri instead of $args.

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list