简体   繁体   English

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

[英]How do I compress HTML code with GZIP or with the .htaccess file?

So I want to compress my HTML code so that my website loads faster: Here's my GH repo所以我想压缩我的 HTML 代码,以便我的网站加载速度更快: 这是我的 GH存储库

I know I need to configure the .htaccess on an Apache server or using GZIP, here's what I did我知道我需要在 Apache 服务器上或使用 GZIP 配置 .htaccess,这就是我所做的

  1. I created a .htaccess file我创建了一个 .htaccess 文件
  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.因此 HTML 代码根本没有被压缩。

And there I haven't seen any tutorial on how to setup this file.而且我还没有看到任何关于如何设置这个文件的教程。

Some help would be much appreciated一些帮助将不胜感激

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.只是 HTML 和 CSS 的新手,但我看到了你的帖子并做了一些研究。 I found this...我找到了这个...

https://youtu.be/QDK2c7rokOw https://youtu.be/QDK2c7rokOw

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM