views:

189

answers:

1

I am trying to compress an excel spreadsheet being sent from my application using apache deflate module. I have added the following line to the my sites-enabled file:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/excel

But is seems to make the response data bigger???

Using firebug, without the module I downloaded the xls spreadsheet from the application and it downloaded 100Kb of data, the file size once on the filesystem was also 100Kb as expected. Once I enabled the deflate module as described above and repeated the process, the amount of data downloaded was 295Kb?? but the file was still only 100Kb once save on the filesystem.

As an experiment I manually gzipped the saved xls file and it compressed to 20Kb.

What am I doing wrong here?

Using deflate (Firebug output):

200 OK   xxxxxxx.co.za   293 KB

4.43s 
ParamsHeadersPostPutResponseCacheHTML
Response Headers 
Date    Tue, 03 Nov 2009 13:01:43 GMT 
Server  Apache/2.2.4 (Ubuntu) mod_jk/1.2.23 PHP/5.2.3-1ubuntu6.4 mod_ssl/2.2.4 OpenSSL/0.9.8e
Content-Disposition attachment; filename="Employee List.xls"
Vary    Accept-Encoding
Content-Encoding    gzip
Content-Type    application/excel

Without deflate (Firebug output):

200 OK     xxxxxxxx.co.za   100 KB

3.46s
ParamsHeadersPostPutResponseCacheHTML
Response Headers
Date    Tue, 03 Nov 2009 13:06:00 GMT
Server  Apache/2.2.4 (Ubuntu) mod_jk/1.2.23 PHP/5.2.3-1ubuntu6.4 mod_ssl/2.2.4 OpenSSL/0.9.8e
Content-Disposition attachment; filename="Employee List.xls"
Content-Length  102912
Content-Type    application/excel
A: 

Try forcing the highest compression level and ensure that other directives affecting compression ratios have sensible values (see mod_deflate reference for more info):

DeflateCompressionLevel 9
DeflateBufferSize 8096
DeflateMemLevel 9
DeflateWindowSize 15

Also according to IANA, the MS Excel content type should be application/vnd.ms-excel, and this is also what my installation Apache/2.2.8 (Ubuntu) returns when asked for an xls file. So it's a bit weird that your Apache doesn't behave similarly. Does the same thing happen for any xls file? If not, there could be something wrong with the particular file.

This is a bit long shot, but what happens if you add application/vnd.ms-excel to the AddOutputFilterByType list?

Eemeli Kantola
I tried changing the mime type to application/vnd.ms-excel and it just ignored it (as if I had not listed the mime type at all), so no luck there
Clinton Bosch
Edit: mod_deflate directive tuning
Eemeli Kantola
By the way, are you by chance accessing your Apache through a proxy?
Eemeli Kantola