如何在 Apache 2.x 中使用 mod_deflate 预压缩文件? [英] How can I pre-compress files with mod_deflate in Apache 2.x?

查看:25
本文介绍了如何在 Apache 2.x 中使用 mod_deflate 预压缩文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过带有 Content-Encoding: zip 的 apache 提供所有内容,但它会即时压缩.我的大量内容是磁盘上的静态文件.我想预先对文件进行 gzip,而不是每次请求时都压缩它们.

I am serving all content through apache with Content-Encoding: zip but that compresses on the fly. A good amount of my content is static files on the disk. I want to gzip the files beforehand rather than compressing them every time they are requested.

我相信,mod_gzip 会在 Apache 1.x 中自动执行此操作,但只是将文件与 .gz 放在一起.mod_deflate 不再是这种情况.

This is something that, I believe, mod_gzip did in Apache 1.x automatically, but just having the file with .gz next to it. That's no longer the case with mod_deflate.

推荐答案

无论如何,这个功能在 mod_gzip 中是错位的.在 Apache 2.x 中,您通过内容协商来做到这一点.具体来说,您需要使用 <启用 MultiViewscode>Options 指令,您需要使用 AddEncoding 指令.

This functionality was misplaced in mod_gzip anyway. In Apache 2.x, you do that with content negotiation. Specifically, you need to enable MultiViews with the Options directive and you need to specify your encoding types with the AddEncoding directive.

这篇关于如何在 Apache 2.x 中使用 mod_deflate 预压缩文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆