Created
April 10, 2012 03:19
-
-
Save zaius/2348131 to your computer and use it in GitHub Desktop.
Serve rails assets with etags from nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location / { | |
if ($uri ~* "/assets/.*-(.*)\..*") { | |
expires max; | |
add_header Cache-Control public | |
add_header Etag $1; | |
} | |
} |
Oh definitely. You can't put that in the if statement though, so you should define it globally at the top of nginx.conf.
Ah I don't user an if statement. I have the following:
location ~ ^/assets/.*-(.*)\..* {
gzip_static on; # to serve pre-gzipped version
expires max;
add_header ETag $1;
add_header Cache-Control public;
break;
}
but looking at that doesn't make since. I don't know that that just applies to just that location
Pretty sure the gzip stuff can be applied per location, but I just have it defined globally. Doesn't seem to cause any problems to do that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll probably also want to add the following to serve the already compressed assets