PHP GZIP 更多信息

发布于 2024-11-25 16:51:50 字数 698 浏览 0 评论 0原文

我使用 google 的 Firefox 插件“速度测试”,出现此错误:

启用压缩
使用 gzip 压缩以下资源可以将其传输大小减少 65.8KiB(减少 65%)。

现在..我对这个主题一无所知,我想了解更多关于这个主题的信息。

这与 OB 相关/连接(如 ob_start )或类似的东西?

我将很乐意获得有关此主题的更多信息和教程。
如果有视频指导就更好了。

这是我从 Google Speed Test 得到的完整通知:

使用 gzip 压缩以下资源可以将其传输大小减少 65.8KiB(减少 65%)。

Compressing http://localhost/english/jquery.js could save 57.3KiB (65% reduction).
Compressing http://localhost/english/javascript/slider.js could save 4.0KiB (69% reduction).
Compressing http://localhost/english/style/style.css could save 3.7KiB (72% reduction).
Compressing http://localhost/english/javascript/home.js could save 853B (62% reduction).

I use the plugin of google for firefox "speed test" and I have this error:

Enable compression
Compressing the following resources with gzip could reduce their transfer size by 65.8KiB (65% reduction).

Now.. I know nothing about this subject and I want to learn more about this subject.

This is related/connected to OB ( like ob_start ) or somthing like that?

I'll be gateful to get more information and tutorials about this subject.

If there are vidoe guides its even better.

This is the full notice that I've got from Google Speed Test:

Compressing the following resources with gzip could reduce their transfer size by 65.8KiB (65% reduction).

Compressing http://localhost/english/jquery.js could save 57.3KiB (65% reduction).
Compressing http://localhost/english/javascript/slider.js could save 4.0KiB (69% reduction).
Compressing http://localhost/english/style/style.css could save 3.7KiB (72% reduction).
Compressing http://localhost/english/javascript/home.js could save 853B (62% reduction).

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

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

发布评论

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

评论(3

无法言说的痛 2024-12-02 16:51:50

看一下 ob_gzhandler。他们也有一个非常简单的例子:

<?php

ob_start("ob_gzhandler");

?>
<html>
<body>
<p>This should be a compressed page.</p>
</html>
<body>

如果浏览器支持gzip,那么该页面将使用gzip压缩并压缩发送,之后浏览器将其解压缩并渲染它。这样做的优点是减少需要传输的字节量。

Take a look at ob_gzhandler. They have a very straight-forward example too:

<?php

ob_start("ob_gzhandler");

?>
<html>
<body>
<p>This should be a compressed page.</p>
</html>
<body>

If the browser supports gzip, then this page will be compressed with gzip and sent compressed, after which the browser will decompress it and render it. The advantage of doing this is lowering the amount of bytes that need to be transferred.

长途伴 2024-12-02 16:51:50

背景

解释

当你想要向您的朋友发送一个大文件,您可以使用 zip、rar 或其他归档程序(如 gzip)对其进行压缩,以节省一些字节并使其更快。

您也可以执行相同的操作并压缩 HTML 页面、JavaScript 和 CSS 文件。

浏览器会自动处理由 gzip (gzipped) 压缩的内容,假设它们获得带有适当 HTTP 响应标头的正确压缩文件。

解决方案

有很多选项可以提供 gzip 压缩内容,例如,

  1. 手动压缩文件并设置正确的 HTTP 标头来提供它们(例如,在 .htaccess 或 PHP 脚本中)
  2. 使用脚本创建 gzip 压缩版本 使用
  3. 输出处理程序gzip 输出(ob_gzhandlerzlib.output-compression
  4. 使用 Apache 模块自动提供 gzip 压缩组件,请参阅mod_deflate
  5. 使用 Google 的页面速度模块

下一步

您的下一步可能是将所有这些文件合并为一个,以最大限度地减少 HTTP 请求。有很多工具可以自动执行此操作。

Background

Explanation

When you want to send a big file to your friend, you compress it using zip, rar, or other archiver like gzip to save some bytes and make it faster.

You may also do the same and compress HTML pages, JavaScript and CSS files.

Browsers do automatically handle content compressed by gzip (gzipped), assuming they get the properly compressed files with appropriate HTTP response headers.

Solutions

There are many options to serve gzipped content, e.g.

  1. Compress the files manually and set the proper HTTP headers to serve them (e.g. in .htaccess or PHP script)
  2. Create the gzipped versions using script
  3. Use output handler to gzip output (ob_gzhandler or zlib.output-compression)
  4. Use Apache module to automatically serve gzipped component, see mod_deflate
  5. Use Google's page speed module

Next step

Your next step will be probably merging all those files into one, to minimize HTTP requests. There are many tools to do this automatically.

灼疼热情 2024-12-02 16:51:50

The traditional way was to use ob_gzhandler. The manual stipulates that using zlib.output-compression, a php.ini directive that globally enables compression is preferred nowadays.

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