Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to enable wordpress gzip compression in linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to enable wordpress gzip compression in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Brief introduction

When Gzip is turned on, the data output to the user's browser will be compressed, which will reduce the amount of data transmitted through the network and improve the speed of browsing.

Gzip compression efficiency is very high, usually up to 70% compression ratio, that is, if your web page has 30K, it becomes about 9K after compression.

Tools / raw materials

Wordpress gzip plug-in

Methods / steps

First: modify the home page file to achieve GZIP (recommended for beginners)

Find the file index.php in the root directory of our wordpress program

And then find it in this file:

Define ('WP_USE_THEMES', true)

Add at the end:

Ob_start ('ob_gzhandler')

This method is the easiest, but it has the drawback that it has to be reset when the wordpress system is upgraded.

Second: modify the .htaccess file to achieve GZIP compression (recommended)

If the server supports .htaccess files, then add the following code to the .htaccess in the wordpress root directory and upload it to the wordpress root directory. There are two kinds of gzip compression codes. The detailed code is as follows. After adding it, upload it to the wordpress root directory to test: (tension itself uses this)

ExpiresActive On

ExpiresByType image/gif A2592000

ExpiresByType image/jpeg A2592000

ExpiresByType image/png A2592000

ExpiresByType image/x-icon A2592000

ExpiresByType application/x-javascript A604800

ExpiresByType text/css A604800

SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript

Third: enable Gzip through php.ini (not recommended to be too complex)

If the server supports php.ini redefinition, you can add the following code to php.ini to turn on gzip.

Zlib.output_compression_level = number (number is the value of 1mur9, and the compression ratio of 1 is the lowest. It is recommended to take 5)

Fourth: install the wordpress gzip plug-in (recommended)

Plug-in name: gzippy

Download address: http://xiazai.jb51.net/201211/yuanma/gzippy_jb51.rar

This method is the simplest, but it is well known for wordpress programs, but using too many plug-ins can cause the site to open too slowly, so the second method is recommended.

Matters needing attention

It should be noted that if the gzip function is disabled in the .htaccess file, it is also necessary to turn on gzip in the .htaccess file after opening it in the php.ini file, otherwise it will have no effect. When the gzip function of wordpress is enabled, the server will compress the page before it is transmitted, which can effectively reduce the bandwidth usage of the server and accelerate the page download. In addition, please note that you can only choose one way to enable wordpress gzip compression, otherwise it may cause conflicts, please keep in mind.

Thank you for reading! This is the end of the article on "how to turn on wordpress gzip compression in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report