如何使用 GZIP 或 .htaccess 文件压缩 HTML 代码?

发布于 2025-01-12 00:45:22 字数 716 浏览 3 评论 0原文

所以我想压缩我的 HTML 代码,以便我的网站加载速度更快: 这是我的 GH 存储库

我知道我需要在 Apache 服务器上配置 .htaccess 或使用 GZIP,这就是我所做的

  1. 我创建了一个 .htaccess 文件
  2. 并输入了命令:
<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

  1. I created a .htaccess file
  2. 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 技术交流群。

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

发布评论

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

评论(1

瑶笙 2025-01-19 00:45:22

我不知道这些,因为我还不喜欢这些!我只是 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

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