3

This Question is Related to my earlier post here: CSS loading issue with Android ICS.

Where I was facing issue with CSS and JS rendering by Android ICS's default and Dolphin browser. This content is served from my Server's Backend Engine, Which uses (Apache2 + FastCGI + Python) setup.

While searching for possible problems, I found that main cause for problem was, content was NOT sent in compressed form from Server.

So sample Response Header looks something as follows:

Connection  Keep-Alive
Content-Encoding    gzip
Content-Length  5997
Content-Type    text/css
Date    Sun, 29 Jul 2012 14:29:08 GMT
Keep-Alive  timeout=15, max=100
Server  Apache (Ubuntu)
Vary    Accept-Encoding

and If Same content is served from flat file. Response header looks something as below. Which is rendered properly by all Browsers.

Accept-Ranges   bytes
Connection  Keep-Alive
Content-Encoding    gzip
Content-Length  1430
Content-Type    text/css
Date    Sun, 29 Jul 2012 14:28:57 GMT
Etag    "a9c06-176d-4c5e693c2a6c0"
Keep-Alive  timeout=15, max=100
Last-Modified   Sat, 28 Jul 2012 16:46:59 GMT
Server  Apache (Ubuntu)
Vary    Accept-Encoding

and Some How, Android ICS's default and dolphin Browser are not able to render the content (Specially css, js content). It works with all other Browsers.

But Essentially, there is some problem with Backend engine also because of which uncompressed data is sent. There are few Interesting points here to look, in Response header:

  1. Response Header contains field that says "Content-Encoding gzip"
  2. But the Content-Length shows the length of Uncompressed version of resource.

To solve the problem I tried few small changes in Architecture, in places where I thought could be a problem cause. I noticed, replacing the fastCGI by CGI solved my Problem and data is sent in Compressed Format now.


Problem

Though the problem is solved but I definitely want to use fastCGI. So I am looking for possible configuration changes that can solve Problem. I have done following Arrangements in Server's Apache settings:

  1. Enabling deflate module from Available Apache modules.
  2. My /etc/apache2/mods-enabled/deflate.conf files has following text:

    <IfModule mod_deflate.c>
              # these are known to be safe with MSIE 6
              AddOutputFilterByType DEFLATE text/html text/plain text/xml
              # everything else may cause problems with MSIE 6
              AddOutputFilterByType DEFLATE text/css
              AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
              AddOutputFilterByType DEFLATE application/rss+xml
    </IfModule>
    
  3. I have following lines to make fastCGI work with my script in /etc/apache2/sites-enabled/default file.

    <Files my_script_name.py>
        SetHandler fastcgi-script 
    </Files>
    
    FastCgiServer /path_to_script/my_script_name.py -processes 4 -socket /tmp/my_script_name.sock
    

Question

I tried various configuration changes But None of them seems to be solving my Problem. Is there any thing that I am missing here to Enable compression with fastCGI?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
lalit
  • 3,283
  • 2
  • 19
  • 26

1 Answers1

2

Finally, I was able to find the solution of problem here: http://wiki.catalystframework.org/wiki/deployment/apache_fastcgi

Here, For answer of a Question: Why is my application so slow, serving blank pages, and/or acting unexpededly? in FAQ section, they clearly say that.

mod_fastcgi and mod_deflate do not coexist well under certain versions of apache (Debian Lenny stock packages for example). A workaround is to not load the deflate module. An alternative solution is to build and install a recent snapshot version of mod_fastcgi (found at http://www.fastcgi.com/dist/).

So as suggested on post, I updated libapache2-mod-fastcgi package on Server and now I am getting compressed data at client side with correct Response header values.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
lalit
  • 3,283
  • 2
  • 19
  • 26