如何 gzip 我的 html 源代码

发布于 2024-08-09 01:53:09 字数 203 浏览 1 评论 0原文

我想对我的网页的 html 源进行 gzip 压缩,在 lighttpd/php5 服务器上执行此操作的最佳方法是什么。

我尝试通过编辑我的 php.ini 文件来做到这一点:

zlib.output_compression = On
zlib.output_handler = On

但它似乎只是透明压缩。

I would like to gzip the html sources of my webpages, what's the best way to do it on a lighttpd/php5 server.

I have tried to do it by editing my php.ini file with:

zlib.output_compression = On
zlib.output_handler = On

but it seems to be a transparent compression only.

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

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

发布评论

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

评论(1

伪装你 2024-08-16 01:53:09

除了在 php 文件中所做的更改之外,您还需要在 lighthttpd 上启用 mod_compress。

http://www.cyberciti.biz/tips/lighttpd- mod_compress-gzip-compression-tutorial.html

编辑:

我相信您正在寻找一个 html 最小化器。如果你检查谷歌发回的标头,它们看起来像这样:

(Status-Line)   HTTP/1.1 200 OK
Date    Thu, 22 Oct 2009 18:28:47 GMT
Expires -1
Cache-Control   private, max-age=0
Content-Type    text/html; charset=UTF-8
Content-Encoding    gzip
Server  gws
Content-Length  3519
X-XSS-Protection    0

如果你想检查你的网络服务器是否正确压缩你的文件,那么“Content-Encoding gzip”就是你要寻找的。

You'll need to enable mod_compress on lighthttpd in addition to the changes you made in your php file.

http://www.cyberciti.biz/tips/lighttpd-mod_compress-gzip-compression-tutorial.html

Edit:

I believe you're looking for an html minimizer then. If you check out the headers that google is sending back they look like this:

(Status-Line)   HTTP/1.1 200 OK
Date    Thu, 22 Oct 2009 18:28:47 GMT
Expires -1
Cache-Control   private, max-age=0
Content-Type    text/html; charset=UTF-8
Content-Encoding    gzip
Server  gws
Content-Length  3519
X-XSS-Protection    0

The "Content-Encoding gzip" is what you're looking for if you want to check for to see if your webserver is properly compressing your files.

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