加快通过简单的Apache设置在网站的.htaccess [zlib.output_com pression + mod_deflate模块]语法 [英] Speeding up Websites via Simple Apache Settings in Htaccess [zlib.output_compression + mod_deflate] a Syntax

查看:181
本文介绍了加快通过简单的Apache设置在网站的.htaccess [zlib.output_com pression + mod_deflate模块]语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下,code这两个块居住在htaccess的加快网站。结果
与在Apache 2.0的PHP 5.2.3

Imagine these two chunks of code residing in htaccess for speeding up the website.
With php 5.2.3 on apache 2.0

块A

# preserve bandwidth for PHP enabled servers
<ifmodule mod_php4.c>
    php_value zlib.output_compression 16386
</ifmodule>

块B

# compress speficic filetypes
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|eot|ttf|svg|xml|ast|php)$">
    SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

这是出现问题:

Q1。这是的适当结合的方式这两个区块A + B成根1 htaccess的?

Q1. Is this the proper way to combine these two blocks A + B into 1 htaccess in the root?

Q2。它是正确的,因为第二块B上的 | PHP | 用于再次在mod_edflate

Q2. Is it correct that on the second block B, |php| is used again in the mod_edflate?

推荐答案

如果mod_deflate模块被加载,你可以控制Apache的配置,那么你应该让阿帕奇做输出COM pression。这样做COM pression在PHP中总是要慢一些。这是我为您推荐的htaccess配置:

If mod_deflate is loaded and you can control apache configuration then you should let apache do output compression. Doing compression in php is always going to be slower. Here is my recommended config for your htaccess:

<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
</IfModule>

我觉得既然有极少数种类不想COM pressed文件的黑名单在这种情况下更有效。你一定要融为一体preSS一切这样一来,即使是那些类型的文件,你可以不记得添加到白名单。

I think a blacklist is more effective in this case since there are very few types of files you don't want compressed. This way you make sure to compress everything else, even those types of files you can't remember to add to a whitelist.

这篇关于加快通过简单的Apache设置在网站的.htaccess [zlib.output_com pression + mod_deflate模块]语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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