Godaddy Windows主机 IIS7 默认是没开启GZIP功能的, 但是GZIP能压缩数据,可加快传输速度。
WordPress有个插件WP-Super-Cache,里面有个选项“Compress pages so they’re served more quickly to visitors.”如果勾选了则是通过程序生成.gz文件来开启GZIP,但Godaddy主机本身是支持GZip压缩输出的,不需要通过程序生成.gz文件开启
以下适用于Godaddy的windows虚拟主机,当然也适合别的本身支持开启gzip的windows主机。
利用web.config文件开启GZip方法:
把如下代码加入到web.config的configuration节点中,也就是在最后一个
</configuration>
上一行加上如下代码:
<system.webServer> <urlCompression doStaticCompression="true" doDynamicCompression="true" /> </system.webServer>
因为Godaddy主机本身是支持GZip压缩输出的,不需要通过程序生成.gz文件开启。
如果网站是WordPress,那么完整的根目录web.config文件如下:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^/$" />
</conditions>
<action type="Redirect" url="/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
<system.webServer>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
</configuration>
现在国内很多主机还不支持GZip
@Firm
即使不支持通过web.config文件开启,也可以使用插件生成.gz文件来开启的。
正准备搬去Godaddy,应该用得着
@手机链 godaddy对wp-super-cache支持并不好吧…
@auapple
设置好了就行,没发现有什么问题~
不错,我一直这样用,感觉要快些