I am uploading content of various types (gif, jpeg, png, css, pdf) to amazon s3. And then I am placing Nginx in front of S3 so I can rewrite urls and have them pulled by azure cdn.
The problem I am running into is sometimes when files are uploaded (various ways but mainly javascript http upload) we often neglect to place the content types. I am trying to figure out if its worth the time to have nginx correct these headers via a serious of location and if statements or should i just remove all content type headers all together.
For example: When i look at this url in Chrome web inspector i dont see a content type header being returned. http://wiki.nginx.org/local/nginx-logo.png.
Are we finally at a point where browsers can themselves determine content types?
Does adding a content type header have any specific PERFORMANCE benefits?
What would be a quick nginx rule to set a content type based on file extensions? For example if the url is mydomain.com/s3reverseproxy/uploads/test.css?querystring=random to set its content type correctly? Current I am using this but worried that a lot of if statements are probably a bad idea:
location ~* ^/s3/(.*) {
# Headers based on file extensions
more_clear_headers 'Content-Type';
if ($request_uri ~* .*svg.*) {
more_set_headers "Content-Type:image/svg+xml";
more_set_headers "X-Content-Type:OverRidden";
}
set $s3_bucket 'mybucket.s3.amazonaws.com';
set $url_full '$1';
# HEADERS
more_set_headers "Server: PROXYS3";
add_header Cache-Control "no-transform,public,max-age=36720000";
etag on;
expires 425d;
.....
Thanks!