Question around Gzip static and CDN

Maxim Dounin mdounin at mdounin.ru
Fri Aug 22 23:35:27 MSD 2008


Hello!

On Fri, Aug 22, 2008 at 09:09:09PM +0530, Rakesh Rajan wrote:

> Hi Maxim,
>
> I am sure the CDN supports gzip. So in case if I configure nginx with  
> gzip ( and not gzip_static ) and there is only test.js , then the CDN  
> works fine ( the CDN response headers contains gzip ). This issue seems  

The curlpit isn't *response* headers, but *request* headers from 
CDN to nginx.  Your CND may support gzip as a server, but don't 
support it being client (i.e. talking to backend servers as client).

Or it may set something in headers that prevents nginx from 
serving gzipped content - e.g. by default nginx doesn't serve 
gzipped content if it detects proxy.  See 
http://wiki.codemongers.com/NginxHttpGzipModule for details.

> quite specific to CDN and having only test.js.gz  on my server ( with  
> nginx configure as gzip_static )

Again: having only test.js.gz on nginx is *misconfiguration*.  
With gzip_static you must have *both* compressed and uncompressed 
versions of file.

Maxim Dounin

>
> Thanks,
> Rakesh
>
> Maxim Dounin wrote:
>> Hello!
>>
>> On Fri, Aug 22, 2008 at 07:03:55PM +0530, Rakesh Rajan wrote:
>>
>>> I have recently moved serving static files from Apache to Nginx (  
>>> 0.7.11  ). As a part of build, I gzip JS and CSS files and have  
>>> complied nginx  using --with-http_gzip_static_module .
>>>
>>> When I access the page using,   
>>> http://static0.<mydomain>.com/js/test.v1.js , nginx serves the page   
>>> fine. The response headers looks like
>>>
>>> /Server nginx/0.7.11
>>> Date Fri, 22 Aug 2008 13:26:12 GMT
>>> Content-Type application/x-javascript
>>> Content-Length 1034
>>> Last-Modified Fri, 22 Aug 2008 12:12:49 GMT
>>> Connection keep-alive
>>> Content-Encoding gzip
>>> Expires Sat, 22 Aug 2009 13:26:12 GMT
>>> Cache-Control max-age=31536000
>>>
>>> /I am using Softlayer CDN ( which is backed by the above nginx ).  
>>> Now,  the same request using the CDN does not work ( returns a 404 ).
>>>
>>> Note: In case I have only test.js ( instead of only test.js.gz )  
>>> then  both nginx and CDN works fine. And in case I have only  
>>> test.js.gz then  only nginx works
>>
>> For gzip_static module you must have both compressed and uncompressed  
>> versions of file.  Compressed one is used when client supports gzip,  
>> and uncompressed one if it doesn't.
>>
>> Since your CDN doesn't work without uncompressed version - it probably  
>> doesn't support gzip (at least doesn't advertize it to nginx) and  
>> gzip_static module is useless here.
>>
>> Maxim Dounin
>>
>
>





More information about the nginx mailing list