Help getting regexp to match to set expires headers

Tim Wong timb8211 at gmail.com
Sun Feb 7 04:51:12 MSK 2010


Hi there,

I'm trying to get nginx to set expires headers only for assets that have
timestamps at the end of them but am having trouble figuring out exactly
what to put in the conf file.  Would anybody be able to help me out?

Here's what I've tried:

# Trying to set expires headers for /test.png?1265332681 but not for /test.png

# Works for /test.png?1265332681 but also matches /test.png
location ~* \.(htc|ico|css|js|gif|jp?g|png)(\?[0-9]+)?$ {
     expires max;
     break;
}

  # No expires headers set
  location ~* \.(ico|css|js|gif|jp?g|png)(\?[0-9]+)$ {
       expires max;
       break;
  }


Thanks,
Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100206/3e2ac512/attachment.html>


More information about the nginx mailing list