我正在尝试使用apache deflate模块压缩从我的应用程序发送的excel电子表格。我已将以下行添加到启用了网站的文件中:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/excel
但似乎使响应数据更大???
使用firebug,没有模块我从应用程序下载了xls电子表格并下载了100Kb数据,文件系统上的文件大小一次也是100Kb。一旦我按上述方法启用了deflate模块并重复了这个过程,下载的数据量就是295Kb ??但是一旦保存在文件系统上,文件仍然只有100Kb。
作为一项实验,我手动压缩保存的xls文件并将其压缩为20Kb。
我在这里做错了什么?
使用deflate(Firebug输出):
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
没有放气(Firebug输出):
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
答案 0 :(得分:0)
尝试强制执行最高压缩级别并确保影响压缩率的其他指令具有合理的值(有关详细信息,请参阅mod_deflate reference):
DeflateCompressionLevel 9
DeflateBufferSize 8096
DeflateMemLevel 9
DeflateWindowSize 15
同样根据IANA,MS Excel内容类型应为application/vnd.ms-excel
,这也是我的安装Apache / 2.2.8(Ubuntu)在被要求提供xls文件时返回的内容。所以你的Apache表现不同,这有点奇怪。对于任何xls文件都会发生同样的事情吗?如果没有,特定文件可能有问题。
这有点长,但如果您将application/vnd.ms-excel
添加到AddOutputFilterByType
列表会怎样?