BlogMatrix
 

Apache mod_deflate problem solved

edit David P. Janes 2007-05-07 12:17 UTC 4 comments  ·

We are trying to serve some of our overlarge Javascript programs using mod_deflate to reduce network traffic and hopefully speed up load times on your end. This could potentially make a lot of difference.

Normal:

$ curl http://semantic.xxx.org/:root/packed/MochiKit_standard.js --head
HTTP/1.1 200 OK
Date: Mon, 07 May 2007 12:09:02 GMT
Server: Apache/2.0.59 (Unix) DAV/2 mod_python/3.2.10 Python/2.4.4
Last-Modified: Sun, 06 May 2007 11:58:48 GMT
ETag: "bf4172-3659a-e83cae00"
Accept-Ranges: bytes
Content-Length: 222618
Vary: Accept-Encoding
Connection: close
Content-Type: application/x-javascript

Compressed:

$ curl http://semantic.xxx.org/:root/packed/MochiKit_standard.js --compressed --head
HTTP/1.1 200 OK
Date: Mon, 07 May 2007 12:08:50 GMT
Server: Apache/2.0.59 (Unix) DAV/2 mod_python/3.2.10 Python/2.4.4
Last-Modified: Sun, 06 May 2007 11:58:48 GMT
ETag: "bf4172-3659a-e83cae00"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 55248
Connection: close
Content-Type: application/x-javascript

But unfortunately, we couldn't start Apache because we were getting the following error:

actl semantic/semantic start
Syntax error on line 862 of /usr/blogmatrix/apache/semantic/semantic/conf/httpd.conf:
Cannot load /usr/blogmatrix/apache/semantic/semantic/modules/mod_deflate.so into server:
/usr/blogmatrix/apache/semantic/semantic/modules/mod_deflate.so: undefined symbol: deflate

The solution turns out to be fairly simple -- just add LoadFile for zlib into the apache conf

LoadFile /usr/lib/libz.so
LoadModule deflate_module modules/mod_deflate.so
AddOutputFilterByType DEFLATE application/x-javascript text/javascript text/css

Comment #1Robert

2007-05-20 16:19:16

We also attempted to serve external js files with mod_deflate enabled for them but found that IE 6 will sometime not load the page or just hangs forever. After disabling mod_deflate for application/x-javascript files things worked as expected minus the compression.

Robert

Comment #2Aldert Berends

2007-06-02 08:19:23

Robert,

Thanks for that comment on deflate + JS + IE 6. The strange thing is that it does not directely start hanging. Also probably the problem has been fixed with an update of IE 6, but not all users update as should...

Aldert

Comment #3mod_deflate problem

2007-06-20 17:21:46

That didn't solve it for me.  I'm trying on Solaris10:

-bash-3.00$ ./apachectl -t -f /usr/local/apache2/conf/test.conf Syntax error on line 1120 of /usr/local/apache2/conf/test.conf: Can't locate API module structure `mod_deflate' in file /usr/local/apache2/modules/mod_deflate.so: ld.so.1: httpd: fatal: mod_deflate: can't find symbol

I tried this method, also:

http://prefetch.net/blog/index.php/2005/12/15/unmangling-apxs-and-mod_deflate/

Comment #4Aldert Berends

2007-06-21 06:47:00

Just forget about mod_deflate...

Just let your users use the cache with (be sure mod_expires is on):

ExpiresActive On ExpiresByType image/gif A100000 ExpiresByType image/png A100000 ExpiresByType image/jpeg A100000 ExpiresByType text/css A100000 ExpiresByType text/javascript A100000 ExpiresByType application/x-javascript A100000 ExpiresByType text/xml A100000

Gzip your PHP output with appropriate settings in php.ini:

output_buffering = 4096 output_handler = ob_gzhandler ;zlib.output_handler =

I ask you what is faster: mod_deflate with problems (also for IE users) or above settings. As far as I know mod_deflate does not use cache, while this combine script does (you dont need to use the combine function), while CACHING the gzipped result: http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files

Also take a look at keep-alive, a better investment.

Success!

Add Comment