This site uses cookies and other tracking technologies to make possible your usage of the website, assist with navigation and your ability to provide feedback, analyse your use of our products and services, assist with our promotional and marketing efforts, and provide better user experience.

By using the website, you agree to our Privacy policy

Accept and continue

Report a bug

Cancel
338
How-to 9 min read September 10, 2019

How to enable Gzip-compression of pages on a site

Enable Gzip compression is a good solution for website optimization because the search engines rank pages with compressed text better. In addition, fast loading pages are more convenient for users. To compress pages, activate one of the modules in .htaccess.

What is Gzip page compression

When opening a page, the browser downloads files with different extensions. Gzip-compression of HTML-pages applies to such file formats: .html, .xml, .js, .css. The larger the size of these files is, the longer the content will load.

If you compress the contents, the server will need less time to process them. It submits files in a compressed form, and the browser unpacks them and displays them in full size on the screen.

Search engines better index sites that use data compression. The transfer of information in this format means faster loading of pages, as a result of which the user does not have to wait long. As a result, submitting files in a compressed form positively affects the ranking of search engines and the loyalty of site visitors.

How to check gzip-compression of the site

Some hosting providers include compression for all their clients by default, despite the server load. On WordPress sites, page content is also immediately compressed. You can check whether the compression technology is connected to your site by CMS or hosting using online services. For example, GidZipTest:
Check GZIP-compression of the site on GidZipTest
You can check the speed of loading a site online using the tool PageSpeed Insights from Google. After analysis, the service issues recommendations for increasing the download speed. Among them, there is often compression advice:
Check GZIP-compression page
Using these and similar online tools, you can check the level of Gzip compression on the sites of OpenCart and other engines. The recommendation for content compression should not be neglected, as it directly affects SEO promotion and the visitor's desire to stay on the site.

To achieve maximum efficiency, one compression will not be enough. It must be used in conjunction with other methods to reduce the weight of pages:

  • use .gif, .jpeg, .png image formats depending on their type;
  • apply caching technology;
  • reduce the size of .css and .js files;
  • Include .css files at the top of the page, and .js at the end;
  • reduce the number of HTTP requests.

All these steps together will reduce the weight of the page, increase the speed of their loading, and have a positive impact on the ranking.

How to enable Gzip compression on Apache

Content compression is dynamic and static. In the first option, data is compressed on the server's side when it is in the path of the browser. An obvious plus of dynamic compression is a significant reduction in the weight and speed of page loading.

The minus is the additional load on the server. Hosting resources may not pull sites with high traffic. You will have to switch to a more expensive tariff or change the provider.

To enable compression in Apache, you need to add a code element to the .htaccess file. Access to it is available in the hosting admin panel or any FTP client:
Enable gzip compression on Apache
After opening the file, activate the mod_deflate module by entering the following commands:
Mod_deflate apache module
If after saving the code, the analysis of the site loading speed again shows the lack of compression, there may be a problem in the server. Some providers use Apache and Nginx server splicing. In this case, you cannot connect compression yourself. The solution will be to contact the service provider of the hosting provider.

If it is impossible to resolve the issue through mod_deflate, try using another mod_gzip module instead. To do this, enter the commands in the .htaccess file:
Mod_gzip apache module
Check if the module worked this time.

Static compression differs from dynamic compression in the absence of server load. You independently compress each file and upload it to the root folder of the site. After that, the server will transmit data to the browser immediately in a compressed form. This step eliminates the need to switch to a more expensive hosting tariff. But after updating the files, you will have to manually create compressed copies of each new document.

To enable static compression, download all the files of the required formats to your computer using the file manager or hosting panel. Next, install the program 7-Zip. Find through the program each file that you want to compress. Right-click on each of them and add it to the archive:
Static GZIP compression
Select the desired format and click "Save":
GZIP format archive in the archiver 7-Zip
After creating the archives of all the files, upload the compressed versions to the root folder. As a result, it will contain compressed and uncompressed versions. To activate static compression, include the mod_rewrite module in the .htaccess file:
Static compression through mod_rewrite module in htaccess
You need to use only one type of compression - dynamic or static. If you connect both methods, in the end, none will work. After implementing each module, you need to check the site again for page loading speed and the presence of content compression.

How to enable Gzip compression on Nginx and other servers

You can determine the type of server on which the site is located in the hosting admin panel or ask the support service of the hosting provider. If your site is located on the Nginx server, you need to enter thein the configuration file /etc/nginx/nginx.conf following fragment:
http {
<...>
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}
Then you will need to restart the server.

If the site is located on Beget, IspManager and you were unable to enable compression by adding a code snippet to .htaccess, contact the hosting support service with a request to enable compression on the server.

How to increase website loading speed on WordPress

To enable Gzip-compression in WordPress, in addition to activating modules on the server, you can also use plugins. For example, in Hyper Cache there is a "Compression" function:
GZIP WordPress Hyper Cache Compression Plugin
When you activate this function, you do not need to connect modules through the .htaccess file in the plugin.

Conclusion

Gzip-compression technology is used to speed up the loading of site pages in conjunction with other actions. The use of text data compression affects the loyalty of visitors and improves the position of the site in the display. You can check the gzip-compression of the site using online services. You can use static or dynamic compression to connect.

In the first case, it is necessary to manually create Gzip archives of each file, thereby reducing the load on the server. In the second option, just plug the module into the .htaccess file and check the Gzip compression of the HTML pages again. If such changes did not work, contact the support service of your hosting provider for help.

Learn how to get the most out of Serpstat

Want to get a personal demo, trial period or bunch of successful use cases?

Send a request and our expert will contact you ;)

Rate the article on a five-point scale

The article has already been rated by 0 people on average out of 5
Found an error? Select it and press Ctrl + Enter to tell us

Share this article with your friends

Sign In Free Sign Up

You’ve reached your query limit.

Or email
Forgot password?
Or email
Back To Login

Don’t worry! Just fill in your email and we’ll send over your password.

Are you sure?

Awesome!

To complete your registration you need to enter your phone number

Back

We sent confirmation code to your phone number

Your phone Resend code Queries left

Something went wrong.

Contact our support team
Or confirm the registration using the Telegram bot Follow this link
Please pick the project to work on

Personal demonstration

Serpstat is all about saving time, and we want to save yours! One of our specialists will contact you and discuss options going forward.

These may include a personal demonstration, a trial period, comprehensive training articles & webinar recordings, and custom advice from a Serpstat specialist. It is our goal to make you feel comfortable while using Serpstat.

Name

Email

Phone

We are glad of your comment
Upgrade your plan

Upgrade your plan

Export is not available for your account. Please upgrade to Lite or higher to get access to the tool. Learn more

Sign Up Free

Спасибо, мы с вами свяжемся в ближайшее время

Invite
View Editing

E-mail
Message
Optional
E-mail
Message
Optional

You have run out of limits

You have reached the limit for the number of created projects. You cannot create new projects unless you increase the limits or delete existing projects.

I want more limits