On the page /page/index.php there is a href leading to /page/index.php?arg=1
The following code adds the page /page/index.php to the cache, but when you try to go to /page/index.php?arg=1, it shows the same page from the cache(/page/index.php) if it is ignored if at all

location=/page/index.php {
        if($is_args!="") {
              proxy_pass http://backend;
              break;
        }
        proxy_pass http://backend;
        proxy_cache nginx;
        proxy_cache_key $scheme $proxy_host $uri;
        proxy_ignore_headers Cache-Control Expires Set-Cookie;
        proxy_cache_valid 10m;
        proxy_cache_methods GET;
    }

1 Answers 1

Better instead of ifwhich, is evil, use proxy_cache_bypass:
location=/page/index.php {
  proxy_pass http://backend;
  proxy_cache nginx;
  proxy_cache_key $scheme $proxy_host $uri;
  proxy_ignore_headers Cache-Control Expires Set-Cookie;
  proxy_cache_valid 10m;
  proxy_cache_methods GET;

  #list each of the possible parameters:
  proxy_cache_bypass $arg_a $arg_b $arg_c;
}
  • Thanks.The proxy_cache_bypass directive was really missing – Alive Ant Oct 10 '19 at 20:01