[英]Enable GZip compression on serving files
Hiii,嗨,
I want to compress output [excluding image only] using GZIP in PHP, how to do so for each type of files [PHP, CSS, JS, HTML]?我想在 PHP 中使用 GZIP 压缩 output [仅不包括图像],如何为每种类型的文件执行此操作 [PHP、CSS、JS、HTML]?
I know the code to work with PHP file only.我只知道使用 PHP 文件的代码。
Use mod_deflate module of Apache more info使用 Apache 的 mod_deflate 模块更多信息
http://httpd.apache.org/docs/2.0/mod/mod_deflate.html http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/ http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
Place this line in your page before any headers or other output.将此行放在页面中任何标题或其他 output 之前。
ob_start("ob_gzhandler");
And for other files you can serve them through php, this could be used if you have mod-rewrite, but no mod-deflate or mod-gzip对于其他文件,您可以通过 php 提供它们,如果您有 mod-rewrite,但没有 mod-deflate 或 mod-gzip,则可以使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.