Skip Location Based On Query String Parameter?

Francis Daly francis at
Thu Nov 13 23:17:49 UTC 2014

On Thu, Nov 13, 2014 at 06:20:05AM -0500, nrahl wrote:

Hi there,

> If the nocache
> parameter is present, it should skip the cache check and go straight to the
> proxy pass.

Untested, but I think that if I needed this, I would probably add an
"if" inside the location{}.

It would need testing, and it does depend on what is in the "apache-pass"
file, but presuming that it does do "proxy_pass" and does not do anything
that is invalid in an "if in location", then

>    location ~ ^/([a-zA-Z0-9\-]+)/ { #Use cache if possible, then proxy pass

       if ($arg_nocache = true) {
         include /etc/nginx/apache-pass;

>       try_files /cache/$1.html.gz /cache/$1.html @apache;
>    }

could possibly work.

(At least until the config is changed in the future to add more if()s
in that location. So don't do that.)

Francis Daly        francis at

More information about the nginx mailing list