{"id":103007,"date":"2021-02-05T09:32:05","date_gmt":"2021-02-05T15:32:05","guid":{"rendered":"https:\/\/wpengine.com\/?post_type=resource&#038;p=103007"},"modified":"2023-09-27T14:59:52","modified_gmt":"2023-09-27T19:59:52","slug":"how-to-enable-gzip-compression-for-wordpress","status":"publish","type":"resource","link":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/","title":{"rendered":"How to Enable GZIP Compression for WordPress"},"content":{"rendered":"\n<p>A slow website can create a lot of problems. It can drive away potential visitors and customers, hurt your site\u2019s User Experience (UX), and even impact your reputation.<\/p>\n\n\n\n<p>Decreasing the size of your website\u2019s pages is key to improving load speeds. Fortunately, GZIP compression is a great method for achieving fast page loading and file size reduction.&nbsp;<\/p>\n\n\n\n<p>In this guide, we\u2019ll look at the basics of GZIP compression, including what it is and what it does. We\u2019ll then detail how to enable GZIP compression on a WordPress website. Let\u2019s jump right in!<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\">What is GZIP Compression?<\/h2>\n\n\n\n<p>GZIP compression is a type of data compression similar to ZIP and RAR. It can be used to compress all the files on your website, whether they&#8217;re text, HTML, CSS, JavaScript, or XML.<\/p>\n\n\n\n<p>GZIP compression occurs before files are served to your visitors\u2019 web browsers. Through this method, GZIP compression reduces the file sizes, which can have a positive effect on website loading times.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Does GZIP Compression do?<\/h2>\n\n\n\n<p>When a visitor lands on your website, their browser requests the site\u2019s files from its server. Your server will compress those files before sending them to the browser. GZIP compression is one method of file compression amongst others.<\/p>\n\n\n\n<p>Compressed files transfer faster than uncompressed files do. This helps to improve website performance and loading speeds \u2013 and as a result, Search Engine Optimization (SEO).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to See If GZIP Compression Is Enabled<\/strong><\/h2>\n\n\n\n<p>GZIP compression is popular, and many <a href=\"https:\/\/wpengine.com\/wordpress-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordPress hosting platforms<\/a> enable it by default. If you are unsure how to check if GZIP compression is working on your site, you can test for it using third-party solutions or in-browser developer tools.&nbsp;<\/p>\n\n\n\n<p>If you do not have GZIP compression enabled, you will generally see warnings in tools such as <a href=\"https:\/\/gtmetrix.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GTmetrix<\/a>. You can also use <a href=\"https:\/\/www.giftofspeed.com\/gzip-test\/\" target=\"_blank\" rel=\"noreferrer noopener\">a GZIP compression tool<\/a> to see whether your website is using GZIP compression.&nbsp;<\/p>\n\n\n\n<p>It is also possible to check if GZIP compression is working by using browser developer tools. When enabled, the response header will include \u201ccontent-encoding: gzip\u201d:<\/p>\n\n\n\n<p>To find the response header in Chrome, you will need to <a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\" target=\"_blank\" rel=\"noreferrer noopener\">open DevTools<\/a> and navigate to <em>Network<\/em>, then reload the page. Click on the name that matches your website, and the response header will open up.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Enable GZIP Compression on WordPress<\/h2>\n\n\n\n<p>All websites on WP Engine <a href=\"https:\/\/wpengine.com\/support\/platform-settings\/#GZIP_Compression\" target=\"_blank\" rel=\"noreferrer noopener\">use GZIP compression<\/a> as a default. All static files including text files, images, CSS, and JavaScript are automatically compressed for optimal website performance. This automatic compression reduces the need for GZIP directives in your <em>.htaccess<\/em> file.&nbsp;<\/p>\n\n\n\n<p>However, not all WordPress websites are hosted on WP Engine, and will not benefit from the default enabling of GZIP compression. If your website is hosted on a different platform, you may need to enable GZIP compression manually. There are several ways to do this, which we\u2019ll look at next.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enable GZIP Compression with a Plugin<\/h3>\n\n\n\n<p>The easiest way to enable GZIP compression is to use a caching plugin. Tools such as <a href=\"https:\/\/wpengine.com\/solution-center\/wp-rocket\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP Rocket<\/a> enable compression by adding code to your <em>.htaccess<\/em> file for you, while others such as <a href=\"https:\/\/wordpress.org\/plugins\/w3-total-cache\/\" target=\"_blank\" rel=\"noreferrer noopener\">W3 Total Cache<\/a> will require you to manually add that code.<\/p>\n\n\n\n<p>While this is generally the simplest method of adding GZIP compression, it does involve adding an extra plugin to your site. If you\u2019re trying to keep your plugin library lean, you can use one of the following solutions instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enable GZIP Compression for Nginx<\/h3>\n\n\n\n<p>If your website uses Nginx, there is a <a href=\"https:\/\/docs.nginx.com\/nginx\/admin-guide\/web-server\/compression\/\" target=\"_blank\" rel=\"noreferrer noopener\">code snippet<\/a> you can use to enable GZIP compression. You need to place the code snippet below in your site\u2019s <em>nginx.conf<\/em> file, in the \u201chttp\u201d section. You can also place this code snippet in the server or location configuration block, but the http section is generally recommended:<\/p>\n\n\n\n<p><code>gzip on;<br>gzip_types text\/plain text\/css text\/javascript image\/svg+xml image\/x-icon application\/javascript application\/x-javascript;<br>gzip_min_length 1000;<br>gzip_vary on;<br>gzip_proxied no-cache no-store private expired auth;<br>gzip_diable \u201cMSIE [1-6];<\/code><\/p>\n\n\n\n<p>Once you\u2019ve saved and closed the file, you will need to restart Nginx. To do so, use the following command:<\/p>\n\n\n\n<p><code>sudo service nginx restart<\/code><\/p>\n\n\n\n<p>After the restart, check to make sure that GZIP compression is active, using the methods previously detailed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Enable GZIP Compression for Apache (By Editing the .htaccess File)<\/strong><\/h3>\n\n\n\n<p>If your web host uses Apache, you will need to edit the <em>.htaccess<\/em> file to enable GZIP compression. This file can be found in the root directory of your WordPress installation, via <a href=\"https:\/\/wpengine.com\/support\/sftp\/\" target=\"_blank\" rel=\"noreferrer noopener\">File Transfer Protocol (FTP)<\/a> or your file manager. Most WordPress GZIP compression methods will require editing the <em>.htaccess<\/em> file.<\/p>\n\n\n\n<p>There are two Apache mods you can use to enable GZIP, but <a href=\"https:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_deflate.html\" target=\"_blank\" rel=\"noreferrer noopener\"><em>mod_deflate<\/em><\/a> is the most widely-supported and best-documented option. To enable <em>mod_deflate<\/em>, add:<\/p>\n\n\n\n<p><code>&lt;IfModule mod_deflate.c&gt;<br>&nbsp;&nbsp;# Compress HTML, CSS, JavaScript, Text, XML and fonts<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/javascript<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/rss+xml<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/vnd.ms-fontobject<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/x-font<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/x-font-opentype<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/x-font-otf<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/x-font-truetype<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/x-font-ttf<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/x-javascript<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/xhtml+xml<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE application\/xml<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE font\/opentype<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE font\/otf<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE font\/ttf<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE image\/svg+xml<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE image\/x-icon<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE text\/css<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE text\/html<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE text\/javascript<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE text\/plain<br>&nbsp;&nbsp;AddOutputFilterByType DEFLATE text\/xml<br><br>&nbsp;&nbsp;# Remove browser bugs (only needed for really old browsers)<br>&nbsp;&nbsp;BrowserMatch ^Mozilla\/4 gzip-only-text\/html<br>&nbsp;&nbsp;BrowserMatch ^Mozilla\/4\\.0[678] no-gzip<br>&nbsp;&nbsp;BrowserMatch \\bMSIE !no-gzip !gzip-only-text\/html<br>&nbsp;&nbsp;Header append Vary User-Agent<br>&lt;\/IfModule&gt;<\/code><\/p>\n\n\n\n<p>To enable <em>mod_gzip<\/em> instead, add:<\/p>\n\n\n\n<p><code>&lt;ifModule mod_gzip.c&gt;<br>mod_gzip_on Yes<br>mod_gzip_dechunk Yes<br>mod_gzip_item_include file \\.(html?|txt|css|js|php|pl)$<br>mod_gzip_item_include mime ^application\/x-javascript.*<br>mod_gzip_item_include mime ^text\/.*<br>mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*<br>mod_gzip_item_exclude mime ^image\/.*<br>mod_gzip_item_include handler ^cgi-script$<br>&lt;\/ifModule&gt;<\/code><\/p>\n\n\n\n<p>Before using either mod, you need to make a backup of your <em>.htaccess<\/em> file and ensure that the module <em>mod_filter<\/em> is on your server, or a 500 error may occur.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Keep Learning with WP Engine<\/h2>\n\n\n\n<p>Reducing the size of your website\u2019s pages can <a href=\"https:\/\/wpengine.com\/resources\/improve-wordpress-site-speed\/\">reduce loading times<\/a> and boost overall performance. GZIP compression can enable this reduction, but only when it is enabled.<\/p>\n\n\n\n<p>Fortunately, here at WP Engine we <a href=\"https:\/\/wpengine.com\/support\/platform-settings\/#GZIP_Compression\">enable GZIP compression<\/a> by default. What\u2019s more, we offer outstanding resources to help you learn how to <a href=\"https:\/\/wpengine.com\/plans\/\">build an outstanding digital experience<\/a> for your visitors!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A slow website can create a lot of problems. It can drive away potential visitors and customers, hurt your site\u2019s User Experience (UX), and even impact your reputation. Decreasing the size of your website\u2019s pages is key to improving load speeds. Fortunately, GZIP compression is a great method for achieving fast page loading and file<span class=\"tile__ellipses\">&hellip;<\/span><span class=\"tile__ellipses--animated\"><\/span><\/p>\n","protected":false},"author":1,"featured_media":145791,"template":"","resource-topic":[912],"resource-role":[896,1296,899],"resource-type":[916],"class_list":["post-103007","resource","type-resource","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using &amp; Enabling GZIP Compressions for WordPress | WP Engine<\/title>\n<meta name=\"description\" content=\"Boost your Wordpress site speed with GZIP compression. Discover how to enable GZIP on Wordpress for rapid load times and improved performance.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using &amp; Enabling GZIP Compressions for WordPress | WP Engine\" \/>\n<meta property=\"og:description\" content=\"Boost your Wordpress site speed with GZIP compression. Discover how to enable GZIP on Wordpress for rapid load times and improved performance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Engine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpengine\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-27T19:59:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2021\/02\/enable-gzip-compression_1200x627.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"627\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2021\/02\/enable-gzip-compression_1200x627.png\" \/>\n<meta name=\"twitter:site\" content=\"@wpengine\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/\",\"url\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/\",\"name\":\"Using & Enabling GZIP Compressions for WordPress | WP Engine\",\"isPartOf\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\"},\"datePublished\":\"2021-02-05T15:32:05+00:00\",\"dateModified\":\"2023-09-27T19:59:52+00:00\",\"description\":\"Boost your Wordpress site speed with GZIP compression. Discover how to enable GZIP on Wordpress for rapid load times and improved performance.\",\"breadcrumb\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wpengine.com\/case-studies\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resources\",\"item\":\"https:\/\/wpengine.com\/case-studies\/resources\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Enable GZIP Compression for WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\",\"url\":\"https:\/\/wpengine.com\/case-studies\/\",\"name\":\"WP Engine\",\"description\":\"Managed Hosting for WordPress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085\",\"name\":\"WP Engine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"caption\":\"WP Engine\"},\"sameAs\":[\"https:\/\/wpengine.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using & Enabling GZIP Compressions for WordPress | WP Engine","description":"Boost your Wordpress site speed with GZIP compression. Discover how to enable GZIP on Wordpress for rapid load times and improved performance.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"Using & Enabling GZIP Compressions for WordPress | WP Engine","og_description":"Boost your Wordpress site speed with GZIP compression. Discover how to enable GZIP on Wordpress for rapid load times and improved performance.","og_url":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/","og_site_name":"WP Engine","article_publisher":"https:\/\/www.facebook.com\/wpengine","article_modified_time":"2023-09-27T19:59:52+00:00","og_image":[{"width":1200,"height":627,"url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2021\/02\/enable-gzip-compression_1200x627.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2021\/02\/enable-gzip-compression_1200x627.png","twitter_site":"@wpengine","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/","url":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/","name":"Using & Enabling GZIP Compressions for WordPress | WP Engine","isPartOf":{"@id":"https:\/\/wpengine.com\/case-studies\/#website"},"datePublished":"2021-02-05T15:32:05+00:00","dateModified":"2023-09-27T19:59:52+00:00","description":"Boost your Wordpress site speed with GZIP compression. Discover how to enable GZIP on Wordpress for rapid load times and improved performance.","breadcrumb":{"@id":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-enable-gzip-compression-for-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/case-studies\/"},{"@type":"ListItem","position":2,"name":"Resources","item":"https:\/\/wpengine.com\/case-studies\/resources\/"},{"@type":"ListItem","position":3,"name":"How to Enable GZIP Compression for WordPress"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/case-studies\/#website","url":"https:\/\/wpengine.com\/case-studies\/","name":"WP Engine","description":"Managed Hosting for WordPress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085","name":"WP Engine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","caption":"WP Engine"},"sameAs":["https:\/\/wpengine.com"]}]}},"acf":[],"grid_image_url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2020\/05\/shutterstock_292336175.jpg","media-type":{"term_id":916,"name":"Article","slug":"article"},"role":"<strong>Roles:<\/strong> Developer, Publisher, Site Owner","topic":"<strong>Topics:<\/strong> Performance","_links":{"self":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource\/103007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource"}],"about":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/types\/resource"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/users\/1"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media\/145791"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media?parent=103007"}],"wp:term":[{"taxonomy":"resource-topic","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-topic?post=103007"},{"taxonomy":"resource-role","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-role?post=103007"},{"taxonomy":"resource-type","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-type?post=103007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}