Skip to content

Cache static media files with nginx

if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)\?[0-9]+$") {
  access_log off;
  expires 31d;
  break;
}
# Matching URLs
http://domain.com/stylesheets/blog.css?1221178271

if ($request_uri ~* "\.(ico|gif|png|jpe?g|css|js|swf)(\?v\d\d?)?$") {
  access_log off;
  expires 31d;
  break;
}
# Matching URLs
http://domain.com/stylesheets/blog.css
http://domain.com/stylesheets/blog.css?v1
http://domain.com/stylesheets/blog.css?v12