conditional "Expires" header config bug

ghazel at gmail.com ghazel at gmail.com
Wed Dec 8 00:09:54 MSK 2010


Hi,

I'm trying to conditionally set the "Expires" header. This tiny
snippet does not work as expected:

    location ~* testing/.*\.png$ {
      if ($request_uri ~* "\.png\?[0-9]+$") {
        expires max;
      }
      try_files $uri /testing/oops.png;
    }

The basic problem is that if the png does not exist and there is a
query string, I get a 404 instead of oops.png. All other combinations
seem to work fine. I have read IfIsEvil, but the alternatives
presented (try_files, return, redirect) do not cover the case of
setting headers.

Is this possible with nginx config? Is there some extension module I
could use to achieve this?

-Greg

P.S. Yes, this is a contrived example. My actual case is to continue
on to an image generating proxy instead of "oops.png". but the error
is the same.



More information about the nginx mailing list