regex - fastcgi_cache_key exclude some args in request uri -
my fastcgi_cache_key is:
fastcgi_cache_key "$host$request_method$request_uri"; my $request_uri has timestamp , signature in it:
/abc/xyz?product_id=10529125896&shop_id=17224077&shop=abc.com&path_prefix=%2fa%2fcomment×tamp=1503044416&signature=882102c51c7b7bd4c5d8521a6565fc70c27b908547316f1123eb4af13b19f2da so, cache miss (because has different timestamp , signature). question is:
i want create new var , use var fastcgi_cache_key. var has this:
myvar
/abc/xyz?product_id=10529125896&shop_id=17224077&shop=abc.com fastcgi_cache_key this:
fastcgi_cache_key "$host$request_method$myvar"; how can ? much.
there 2 ways it.
if ($request_uri ~ "([^\?]*)\?(.*)timestamp=([^&]*)&?(.*)") { set $args $2$4; } fastcgi_cache_key "$host$request_method$args"; this remove timestamp. can either modify pattern ignore 1 more field or can use twice remove field $args.
next option use openresty or nginx lua allows execute lua script in code. if conditions not considered good. having lua increases software requirement
Comments
Post a Comment