3

我正在尝试使用 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。

我在这里做错了什么?

使用放气(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
4

1 回答 1

0

尝试强制使用最高压缩级别并确保影响压缩比的其他指令具有合理的值(有关更多信息,请参阅mod_deflate 参考):

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-excelAddOutputFilterByType列表中会发生什么?

于 2009-11-10T22:14:48.843 回答