Introduction: This article focuses on Internet website building technology-how to use Gzip compression to greatly improve page loading speed? Provide tutorials on website creation, website operation, SEO, and website promotion to help small and medium-sized webmasters grow rapidly.
Page loading time is the most important part of website user experience. Once your independent website cannot be opened within 3 seconds, more than 90% of visitors will choose to close the page and no longer visit it. Then the SEO ranking will be reduced and PPC advertising will be wasted.
Therefore, website speed optimization is crucial.
Although there are many ways to increase the opening speed of independent websites, there is one method that is often overlooked.
That is Gzip compression.
Today I will introduce the basics and working principles of Gzip compression in detail, and finally teach you how to implement it on a WordPress website.
Before officially starting today’s tutorial, let me share a story.
Do you know why Google’s default search results are 10, not 20, 30 or 100?
In fact, Google didn’t know how many search results to display in the early days, so they simply asked questions online and consulted everyone’s opinions. In the end, 30 results per page won, but Google found that the more search results there were, the longer the entire search would take to display. With the technology at the time, 30 results were 0.5 seconds slower than 10 results, so Google finally adjusted the search results to 10, which is what you see now.
OK, the story is over, let’s get into today’s topic, Gzip compression.
Directory
How to enable Gzip compression on an independent site?
How to test whether Gzip compression is enabled on an independent site?
What is Gzip compression?
Gzip is a software application for file compression and decompression.
If Gzip compression is used on the server, the compression rate of the overall website file is over 70%. HTML, CSS and JavaScript will be significantly reduced, but Gzip cannot be used to compress images and videos.
Smaller files mean less data transmission and less server pressure, so using Gzip can significantly increase the loading speed of website pages and improve user experience.
If Gzip compression is not used, you will find the following errors when you use the website speed test tool.
Error reported by Google PageSpeed Insights.
GTmetrix error.
How to enable Gzip compression on an independent station?
If you are using a WordPress foreign trade independent station, the easiest way is to use the out-of-the-box WordPress host SiteGround. Their self-developed supercache cache has this function.
If you are not using SiteGround, the simpler way is to install a cache plug-in. Babubu recommends WP Fastest Cache, which is the best free cache plug-in in my opinion.
If you want to manually solve Gzip compression, you can also do it by editing the .htaccess file.
The .htaccess file is a core file of WordPress, so please make a backup before editing it, just in case.
First, enter the WordPress root directory public_html through FTP software, find the .htaccess file and download it for backup.
Then open it with Notepad++ and add the following code on a new line after # END WordPress.
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Older Browsers Which Can’t Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatchbMSIE!no-gzip!gzip-only-text/html
</IfModule>
The above code works for most servers. If it doesn’t work, you can also try the following code.
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_include mime ^text/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_include handler ^cgi-script$
</ifModule>
Finally, save your .htaccess file and upload it to the wordpress root directory public_html.
How to test whether Gzip compression is enabled on an independent site?
Whether Gzip is enabled can be detected using Check GZIP compressionl.
If it passes, there will be a prompt as shown in the figure below.
Summary
In terms of wordpress foreign trade independent station speed optimization, Gzip compression is one of the few most direct and effective methods.
By compressing HTML, CSS, and JavaScript files, you can clearly feel the improvement of website speed.
So when you see this article, you might as well give it a try.
After reading this article, let’s summarize the knowledge points involved in this article, including Gzip compression, compressed web pages, loading speed and other aspects. I hope these can help you better understand the topic of the article.
Statement: Some of the content of this website comes from the Internet. If the article infringes your rights, please contact us in time and we will verify and deal with it.