如何使用 GZIP 或 .htaccess 文件压缩 HTML 代码?
所以我想压缩我的 HTML 代码,以便我的网站加载速度更快: 这是我的 GH 存储库
我知道我需要在 Apache 服务器上配置 .htaccess 或使用 GZIP,这就是我所做的
- 我创建了一个 .htaccess 文件
- 并输入了命令:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
问题是我要增强的网站没有(并且不得)有一个与之通信的服务器。它基本上是一个仅前端的项目。因此 HTML 代码根本没有被压缩。
我还没有看到任何有关如何设置此文件的教程。
一些帮助将不胜感激
So I want to compress my HTML code so that my website loads faster:
Here's my GH repo
I know I need to configure the .htaccess on an Apache server or using GZIP, here's what I did
- I created a .htaccess file
- entered the commands:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
The problem is that the website I'm supposed to enhance does not (and MUST not) have a server to communicate it with. It's basically a Front-End only project. Thus the HTML code does not get compressed at all.
And there I haven't seen any tutorial on how to setup this file.
Some help would be much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这些,因为我还不喜欢这些!我只是 HTML 和 CSS 的新手,但我看到了你的帖子并做了一些研究!我发现了这个...
https://youtu.be/QDK2c7rokOw
I don't know any of these as I am not into these yet! Just a newbie on HTML and CSS but I saw your post and did some research! I found this...
https://youtu.be/QDK2c7rokOw