GZIP is a file compression technique and has to be enabled on server-side. GZIP compression allows you to compress the size of your assets (HTML, CSS, and JS). GZIP compression is one of the quickest and easiest optimizations when it comes to speeding up WordPress.

Setting up GZIP in WordPress is very easy, all you will need to do is copy-paste lines of code to your .htaccess file. Apache mod_deflate module is used for compressing content before serving to client.

There are plugins out there that can enable GZIP for you, from the performance and usage perspective, it's better to restrict plugins as much as possible.

Steps to enable Apache gzip compression using cPanel web interface:

  • Open your cPanel account: https://mydomain.com:2083
  • Find and click 'Optimize Website' option under 'Software section
  • You will three options on this page:
    • Disabled – Select this option to disable gzip compression for you website.
    • Compress all content – Select this option to compress all your website’s content.
    • Compress the specified MIME types – Select this option and enter the MIME types in below text box to compress specific files only.

Click on 'Update Settings' and you have successfully enabled GZIP compression on your site.

Next, open the .htaccess file, from the root directory and add the following rules. These rules specifiy the file types where Gzip will be applied and also making sure that we keep compatibility with some really old browsers.

<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 Gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-Gzip
BrowserMatch \bMSIE !no-Gzip !Gzip-only-text/html
Header append Vary User-Agent
</IfModule>


And, we are done! You can click here to check the GZIP Compression for your website.