# Gzip compression not working

**URL:** <https://www.ruby-forum.com/t/gzip-compression-not-working/138232>\
**Category:** NGINX\
**Created:** [May 21, 2008, 7:37am UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232 "2008-05-21T07:37:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 21, 2008, 7:37am UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/1 "2008-05-21T07:37:55Z")

</div>

Hello,  
I have a fresh new installation of nginx on ubuntu 8.04 (installed via  
apt-get, I believe it is 0.5.x something)

In my nginx.conf file I have gzip turned on, now I wanted to do a basic  
test  
and serving a static html file, but the file does not come compressed at  
all.

Here’s the snippet of configuration, I tried variations on this without  
success

gzip on;  
gzip\_min\_length 1100;  
gzip\_buffers 4 8k;  
gzip\_proxied any;  
gzip\_types text/plain text/html text/css  
application/x-javascript  
text/xml application/xml application/xml+rss text/javascript;  
gzip\_http\_version 1.1;  
gzip\_comp\_level 6;

Does anyone have any idea why nothing is compressed?

I’ve used this [GIDZipTest: Web Page Compression (Deflate / Gzip) Test - GIDNetwork](http://www.gidnetwork.com/tools/gzip-test.php) and others  
to  
test the results.

Thank you so much!

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 21, 2008, 6:38pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/2 "2008-05-21T18:38:40Z")

</div>

Christian,

Is the test file you are testing larger than 1100 bytes and one of the  
formates you listed in gzip\_types?

If you have curl (linux, BSD, ect.) installed you can do your own  
header tests with: curl -I --compressed [http://localhost](http://localhost)

Nginx “how to”  
[Nginx Secure SSL Web Server @ Calomel.org](https://calomel.org/nginx.html)

–  
Calomel @ [https://calomel.org](https://calomel.org)  
Open Source Research and Reference

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 21, 2008, 6:45pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/3 "2008-05-21T18:45:19Z")

</div>

On Wed, May 21, 2008 at 12:24:39AM -0500, Christian B. wrote:

> I’ve used this [GIDZipTest: Web Page Compression (Deflate / Gzip) Test - GIDNetwork](http://www.gidnetwork.com/tools/gzip-test.php) and others to  
> test the results.

[www.gidnetwork.com](http://www.gidnetwork.com) send HTTP/1.0 request, which is not gzipped because  
of “gzip\_http\_version 1.1”.

Also, you do not need to set gzip\_types, those never be issued by nginx:

application/xml, application/xml+rss, text/javascript.

It’s CPU cycles waste.

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 21, 2008, 7:37pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/4 "2008-05-21T19:37:45Z")

</div>

On Wed, May 21, 2008 at 01:00:53PM -0400, Calomel wrote:

> Igor,
> 
> Why do you not need to specify “gzip\_types”? Is it because he is using  
> “gzip\_proxied any;” ?

No. The gzip modules tests Content-Type sequentially, so the shorter  
list is the better. The “application/xml, application/xml+rss,  
text/javascript”  
are not defined in nginx’s mime.types. However, they may be set by a  
backend.

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 21, 2008, 7:16pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/5 "2008-05-21T19:16:02Z")

</div>

Igor,

Why do you not need to specify “gzip\_types”? Is it because he is using  
“gzip\_proxied any;” ?

–  
Calomel @ [https://calomel.org](https://calomel.org)  
Open Source Research and Reference

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 22, 2008, 8:07pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/6 "2008-05-22T20:07:18Z")

</div>

Hi guys, ok just removing the file size did work…and the http test as  
well. Now should I be concerned with gzip\_http at all? what is going to  
give me compression for most clients out there?  
Thanks for the tip on the types as well.

Christian

On Wed, May 21, 2008 at 11:24 AM, Calomel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > test and serving a static html file, but the file does not come  
> > text/javascript;  
> > Visible links
> > 
> > 1. [GIDZipTest: Web Page Compression (Deflate / Gzip) Test - GIDNetwork](http://www.gidnetwork.com/tools/gzip-test.php)

–

Christian B.  
Director of IT  
[Warmlyyours.com](http://Warmlyyours.com), inc.

Phone: (800) 875-5285 ext.800  
Fax: (847) 550-2600  
Email: removed\_email\_address@domain.invalid

WarmlyYours  
Honeywell authorized licensee  
2 Corporate Dr., Suite 100  
Long Grove, Illinois 60047

Visit the WarmlyYours website at: [www.warmlyyours.com](http://www.warmlyyours.com)

24/7 Installation Support â€¢ Lifetime Technical Assistance â€¢ Free Design  
Service  
This email and any files transmitted with it are confidential and  
intended  
solely for the use of the individual or entity to whom they are  
addressed.  
If you have received this email in error please notify the system  
manager.  
Please note that any views or opinions presented in this email are  
solely  
those of the author and do not necessarily represent those of the  
company.

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 22, 2008, 8:13pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/7 "2008-05-22T20:13:11Z")

</div>

This is my revised setting, I had to set proxy\_set\_header for it to  
compress, not sure what it does or why.

As for the gzip types, shouldn’t text/javascript be compressed? should  
we  
add it to the mime types?

Thank you

```
gzip on;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types text/plain text/html text/css 

```

application/x-javascript  
text/xml application/xml application/xml+rss text/javascript;  
gzip\_comp\_level 4;  
gzip\_http\_version 1.0;  
proxy\_set\_header Accept-Encoding “”;

On Thu, May 22, 2008 at 12:51 PM, Christian B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > ## Christian,
> > 
> > > test and serving a static html file, but the file does not come  
> > > application/x-javascript text/xml application/xml application/xml+rss
> 
> Director of IT
> 
> Visit the WarmlyYours website at: [www.warmlyyours.com](http://www.warmlyyours.com)
> 
> 24/7 Installation Support â€¢ Lifetime Technical Assistance â€¢ Free Design  
> Service  
> This email and any files transmitted with it are confidential and intended  
> solely for the use of the individual or entity to whom they are addressed.  
> If you have received this email in error please notify the system manager.  
> Please note that any views or opinions presented in this email are solely  
> those of the author and do not necessarily represent those of the company.

–

Christian B.  
Director of IT  
[Warmlyyours.com](http://Warmlyyours.com), inc.

Phone: (800) 875-5285 ext.800  
Fax: (847) 550-2600  
Email: removed\_email\_address@domain.invalid

WarmlyYours  
Honeywell authorized licensee  
2 Corporate Dr., Suite 100  
Long Grove, Illinois 60047

Visit the WarmlyYours website at: [www.warmlyyours.com](http://www.warmlyyours.com)

24/7 Installation Support â€¢ Lifetime Technical Assistance â€¢ Free Design  
Service  
This email and any files transmitted with it are confidential and  
intended  
solely for the use of the individual or entity to whom they are  
addressed.  
If you have received this email in error please notify the system  
manager.  
Please note that any views or opinions presented in this email are  
solely  
those of the author and do not necessarily represent those of the  
company.

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [May 24, 2008, 1:16pm UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/8 "2008-05-24T13:16:08Z")

</div>

On Thu, May 22, 2008 at 01:03:40PM -0500, Christian B. wrote:

> This is my revised setting, I had to set proxy\_set\_header for it to  
> compress, not sure what it does or why.

proxy\_set\_header Accept-Encoding “”;

disables this header when request is proxied to backend.  
However, any proxy\_set\_header in a locaiton resets proxy\_set\_header  
inherited from previous level, therefore you should add it in these  
locaitons instead of global level.

> As for the gzip types, shouldn’t text/javascript be compressed? should we  
> add it to the mime types?

There are no text/javascript MIME-type. At least in Apache configuration  
files.

---

<div class="post-metadata">

**Author:** ![chrisbotor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@chrisbotor](https://www.ruby-forum.com/u/chrisbotor)\
**Post date:** [December 30, 2015, 9:42am UTC](https://www.ruby-forum.com/t/gzip-compression-not-working/138232/9 "2015-12-30T09:42:46Z")

</div>

i find a free online service to minify js  
[online-code.net&nbsp;-&nbsp;online code Resources and Information.](http://www.online-code.net/minify-js.html) and compress css  
[online-code.net&nbsp;-&nbsp;online code Resources and Information.](http://www.online-code.net/minify-css.html), so it will reduce the size  
of web page.
