With nginx I have
server {
listen 1.2.3.4:80
proxy_cache_valid 200 302 5m;
location / {
try_files $uri @upstream;
root $root;
}
}
When I go http://example.com/foobar
it generates a redirect to http://example.com/foobar?filter_distance=50&...
which is visitor dependent so I would like to not cache this redirect. I need to bypass cache when the query string is empty. I am a bit lost because location /foobar
will match both.
I added
to the http section and
to the server section. This seems to be working.
You should use the
proxy_cache_bypass
andproxy_no_cache
directives like this:Definition of
proxy_no_cache
from nginx documentationHere we test if the filter_distance GET parameter is empty. If it is, we set $nocache to 1, and then the
proxy_cache_bypass
andproxy_no_cache
directives will get active.You can add other GET parameters similary, for example
$arg_filter_type
, if you have afilter_type
GET parameter.