matt
January 29, 2008, 10:34pm
1
I¹m having a difficult time getting files (.js, .png) to gzip under my
configuration. Can someone tell me if I¹m doing something wrong?
Django project
server {
listen 80;
server_name dev.foo.com ;
location ^~ /media {
root /usr/local/backyardpost/trunk/static/admin;
access_log on;
access_log /var/log/nginx/static_media.log download;
}
location ~*
^.+.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wa
v|rtf|mpeg)$ {
limit_rate 2000K;
access_log /var/log/nginx/django_media.log download;
access_log on;
}
location / {
fastcgi_pass 127.0.0.1:8080;
include bots.conf;
include fastcgi.conf;
access_log /var/log/nginx/django.log main;
}
# output compression saves bandwidth
gzip on;
gzip_http_version 1.0;
gzip_min_length 1100;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml
application/x-javascript application/pdf application/xml
application/xml+rss
text/javascript;
}
Seems like some things (HTML) are being gzipped by nginx automatically,
but
I have a JavaScript file being served at:
Foo.com that isn¹t being
gzipped.
The file is 6.7K, so it doesn¹t make sense to me. I have a CSS file at
Foo.com that supposedly is
being
gzipped (it is 6.3K).
Any idea what¹s going on?
Also, I am using Yahoo!¹s Yslow plugin for Firefox to detect what
components
are being gzipped. Should I be looking at something else instead?
Thanks,
Matthew
matt
January 29, 2008, 10:39pm
2
Look at the http headers during a request.
It is probably being compressed (the js files).
Not sure why you are trying to compress png and pdf files on the fly.
matt
January 29, 2008, 10:49pm
3
Not sure why you are trying to compress png and pdf files on the fly.
'Cause I’m a beginner. Thanks!
Matt
matt
January 30, 2008, 3:01am
4
gzip_types application/x-javascript
2008/1/30, Matthew W. [email protected] :
matt
January 30, 2008, 5:36am
5
I do have that in the list. Are you saying to only have that one, or as
a
separate directive, or what?
On 1/29/08 8:51 PM, “焦胜强” [email protected] wrote:
On 1/29/08 4:32 PM, “eliott” [email protected] wrote:
access_log /var/log/nginx/static_media.log download;
}
location ~*
^.+.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav
matt
January 30, 2008, 6:10am
6
do this:
curl -S -I -H “Accept-Encoding:gzip”
http://dev.foo.com/site_media/js/backyardpost.js
HTTP/1.1 200 OK
Server: nginx/0.5.34
Date: Wed, 30 Jan 2008 04:49:43 GMT
Content-Type: application/x-javascript
Last-Modified: Sat, 29 Dec 2007 04:01:49 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Expires: Wed, 30 Jan 2008 05:19:43 GMT
Cache-Control: max-age=1800
Content-Encoding: gzip
在08-1-30,Matthew W. [email protected] 写é“:
matt
January 30, 2008, 2:40pm
7
By the way, the backyardpost.css file header looks like this (I see the
‘gzip’ in the Content-Encoding):
HTTP/1.1 200 OK
Server: nginx/0.6.16
Date: Wed, 30 Jan 2008 12:27:17 GMT
Content-Type: text/css
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
Last-Modified: Fri, 25 Jan 2008 03:07:01 GMT
Vary: Cookie
Set-Cookie: uid=QwqV0UegbSUAABS2AwMGAg==; expires=Thu, 31-Dec-37
23:55:55
GMT; path=/
Content-Encoding: gzip
Thanks again,
Matt
On 1/30/08 12:00 AM, “moda” [email protected] wrote:
Connection: keep-alive
On 1/29/08 8:51 PM, “焦胜强” [email protected] wrote:
On 1/29/08 4:32 PM, “eliott” [email protected] wrote:
Look at the http headers during a request.
It is probably being compressed (the js files).
Not sure why you are trying to compress png and pdf files on the fly.
On 1/29/08, Matthew W. [email protected] wrote:
I’m having a difficult time getting files (.js, .png) to gzip under
my
root
/usr/local/backyardpost/trunk/static/admin;
access_log on;
access_log /var/log/nginx/static_media.log download;
}
location ~*
^.+.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi>>>>>>
|wav
matt
January 30, 2008, 2:42pm
8
Adding “text/x-js†to my gzip_content_types worked! Yay! Thanks.
Matt
On 1/30/08 12:00 AM, “moda” [email protected] wrote:
Connection: keep-alive
On 1/29/08 8:51 PM, “焦胜强” [email protected] wrote:
On 1/29/08 4:32 PM, “eliott” [email protected] wrote:
Look at the http headers during a request.
It is probably being compressed (the js files).
Not sure why you are trying to compress png and pdf files on the fly.
On 1/29/08, Matthew W. [email protected] wrote:
I’m having a difficult time getting files (.js, .png) to gzip under
my
root
/usr/local/backyardpost/trunk/static/admin;
access_log on;
access_log /var/log/nginx/static_media.log download;
}
location ~*
^.+.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi>>>>>>
|wav
matt
January 30, 2008, 2:38pm
9
Awesome tip! Thanks!
So maybe I need to add text/x-js to my list, not just
application/x-javascript?
HTTP/1.1 200 OK
Server: nginx/0.6.16
Date: Wed, 30 Jan 2008 12:26:03 GMT
Content-Type: text/x-js
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
Last-Modified: Fri, 18 Jan 2008 21:38:30 GMT
Vary: Cookie
Set-Cookie: uid=QwqV0UegbNsAABS2AwMFAg==; expires=Thu, 31-Dec-37
23:55:55
GMT; path=/
On 1/30/08 12:00 AM, “moda” [email protected] wrote:
Connection: keep-alive
On 1/29/08 8:51 PM, “焦胜强” [email protected] wrote:
On 1/29/08 4:32 PM, “eliott” [email protected] wrote:
Look at the http headers during a request.
It is probably being compressed (the js files).
Not sure why you are trying to compress png and pdf files on the fly.
On 1/29/08, Matthew W. [email protected] wrote:
I’m having a difficult time getting files (.js, .png) to gzip under
my
root
/usr/local/backyardpost/trunk/static/admin;
access_log on;
access_log /var/log/nginx/static_media.log download;
}
location ~*
^.+.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi>>>>>>
|wav