在 PHP 服务器上启用 GZIP?

发布于 2024-09-15 12:02:29 字数 223 浏览 3 评论 0原文

我正在疯狂地提高我的网站速度并在合理范围内优化我可以做的事情,我想做的一件事是编辑一些 Apache/MySQL 配置,这样我就可以减少页面加载时间,我想尝试使用 .htaccess 但我讨厌随之而来的 500 个错误,因为我有 PHP,我希望在那里进行 GZIP 压缩。

我会添加什么,以及一些关于如何在我自己的代码中实现它的指示?

另外,GZIP 是哪个压缩库的一部分?

I was going on a binge to increase speed of my website and optimize what I can within reason, one thing I wanted to go into was editing some Apache/MySQL configurations so I can decrease page loading time, I wanted to try something with .htaccess but I hate 500 errors that ensues, as I got PHP I'm wishing to do GZIP compression there.

What would I add, and some pointers on how I should implement it in my own code?

And also, GZIP is a part of what compression library?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疑心病 2024-09-22 12:02:29

按照惯例,您只需将 ob_start("ob_gzhandler") 添加到页面的开头,确保您事先不输出任何内容,它将为您处理其余的所有事情。您可能需要确保浏览器不是 Netscape (3),因为它无法处理 GZ 编码。

而且,GZIP 是哪个压缩库的一部分?

GZIP 是 ZLib 库的一部分,因此需要它作为依赖项。

Conventionally you would only need to add ob_start("ob_gzhandler") to the first of your page, be sure you output no content beforehand and it will take care of all of the rest for you. You may want to ensure the browser isn't Netscape (3) as it can't handle GZ encodings.

And also, GZIP is a part of what compression library?

GZIP is part of the ZLib library, and thus requires it as a dependancy.

魂归处 2024-09-22 12:02:29

您可以在 php.net 网站上获取更多信息(例如 php.net/ob_start )

You can get more information on php.net site ( php.net/ob_start for examplle )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文