开发者

How to configure apache to serve already compressed files?

开发者 https://www.devze.com 2023-03-15 11:57 出处:网络
I would like to know if it is possible to configure apache to deliver files that are already gzipped on the filesystem.

I would like to know if it is possible to configure apache to deliver files that are already gzipped on the filesystem.

I mention that I want apache to deliver these files using HTTP compression protocol.

If this is possible it should work like this: A file.txt.gz is stored on the server and a client (supporting compression) makes a request for file file.txt, the server would send the 开发者_StackOverflow中文版compressed file to the client.


According to the author of this page, you can serve your compressed files. First, add a type handler:

AddType "text/css;charset=UTF-8" .cssgz
AddEncoding gzip .cssgz

Then rewrite all requests for *.txt to *.txt.gz:

RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule (.*)\.txt$ $1\.txt.gz [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消