简体   繁体   English

对服务文件启用 GZip 压缩

[英]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 文件的代码。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM