How can I get Apache gzip compression to work?

enable gzip compression apache ubuntu
gzip compression online
enable gzip compression apache centos
check gzip compression
gzip compression wordpress
gzip compression not working
gzip compression htaccess gtmetrix
apache gzip json

I can't get my site to use gzip compression.

I recently watched this video by Chris Coyier over at css-tricks.com. In the video, he talks about enabling gzip compression to make websites run faster.

As per his instruction, I linked through to github via html5boilerplate.com, copied the gzip compression code from their .htaccess file, pasted it into my own, and uploaded it to my site.

I've tested it via gzipwtf.com and it doesn't seem to work. Can anyone help me with this?

My .htaccess file looks like this:

# ----------------------------------------------------------------------
# Trim www
# ----------------------------------------------------------------------

RewriteEngine On
RewriteCond %{HTTP_HOST} !^orbitprint.com$ [NC]
RewriteRule ^(.*)$ http://orbitprint.com/$1 [L,R=301]

# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------

<IfModule mod_deflate.c>

  # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  <IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
      SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
      RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
  </IfModule>

  # Compress all output labeled with one of the following MIME-types
  <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/atom+xml \
                                  application/javascript \
                                  application/json \
                                  application/rss+xml \
                                  application/vnd.ms-fontobject \
                                  application/x-font-ttf \
                                  application/xhtml+xml \
                                  application/xml \
                                  font/opentype \
                                  image/svg+xml \
                                  image/x-icon \
                                  text/css \
                                  text/html \
                                  text/plain \
                                  text/x-component \
                                  text/xml
  </IfModule>

</IfModule>

Try this :

####################
# GZIP COMPRESSION #
####################
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip

How to enable Gzip compression in Apache, Look for your site in the file and find the line that starts with <Directory> - add the code above into that section and save the file. The code below should be added to your .htaccess file </ifModule> Save the .htaccess file and then refresh your webpage. Check to see if your compression is working using the Gzip compression tool. Enable compression on Apache webservers The instructions and code above will work on Apache.


It is better to implement it as in the snippet below.

Just paste the content below in your .htaccess file, then, check the performance using: Google PageSpeed, Pingdom Tools and GTmetrics.

# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>

# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 7200 seconds"
  ExpiresByType image/gif "access plus 2678400 seconds"
  ExpiresByType image/jpeg "access plus 2678400 seconds"
  ExpiresByType image/png "access plus 2678400 seconds"
  ExpiresByType text/css "access plus 518400 seconds"
  ExpiresByType text/javascript "access plus 2678400 seconds"
  ExpiresByType application/x-javascript "access plus 2678400 seconds"
</ifmodule>

# Cache Headers
<ifmodule mod_headers.c>
  # Cache specified files for 31 days
  <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
  # Cache HTML files for a couple hours
  <filesmatch "\.(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
  # Cache PDFs for a day
  <filesmatch "\.(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  # Cache Javascripts for 31 days
  <filesmatch "\.(js)$">
  Header set Cache-Control "max-age=2678400, private"
  </filesmatch>
</ifmodule>

Check GZIP Compression Status, for your website. You can also add this code in website's . htaccess file in the site root. Enable GZIP on Apache. The second way to enable Gzip compression is by editing your .htaccess file. Most shared hosts use Apache, in which you can simply add the code below to your .htaccess file. You can find your .htaccess file at the root of your WordPress site via FTP.


Enable GZIP Compression in WordPress: The 110% Guide, dashboard > WP Super Cache > Advanced > check the box for Compress pages so they're served more quickly to visitors. GZIP compression is completely automated in WP Rocket; it doesn’t appear in the plugin’s settings, but quietly works its magic under the hood to make your site faster. 3. Enable GZIP Compression on Apache. If your site is hosted on a shared server, you can add the following code to your .htaccess file. You’ll find this file in the root folder of your site using cPanel, FTP, or whatever method you use to access your site’s files.


First of all go to apache/bin/conf/httpd.conf and make sure that mod_deflate.so is enabled.

Then go to the .htaccess file and add this line:

SetOutputFilter DEFLATE

This should output all the content served as gzipped, i have tried it and it works.

How to setup caching & GZIP compression in Apache Web Server , Configure Gzip Compression​​ Now edit your apache configuration and add the extensions you want to compress. Add the following configuration in Apache Virtual Host to enable gzip compression for your website. You can also add this code in website's . htaccess file in the site root. To enable gzip compression on Tomcat, browse to your $CATALINA_HOME/conf directory ($CATALINA_HOME is the directory where you’ve installed Tomcat) and open the server.xml file. In the Service collection, edit the Connector that you want to enable gzip compression on and edit as per the following example:


Ran into this problem using the same .htaccess configuration. I realized that my server was serving javascript files as text/javascript instead of application/javascript. Once I added text/javascript to the AddOutputFilterByType declaration, gzip started working.

As to why javascript was being served as text/javascript: there was an AddType 'text/javascript' js declaration at the top of my root .htaccess file. After removing it (it had been added in error), javascript starting serving as application/javascript.

How to Enable Gzip Compression in Apache Web Server, To enable caching and compression, we use the .htaccess file. If there is no such file, just create it (notice there is nothing before the dot!). How to enable GZIP in  You can try a couple of things if gzip compression doesn't work. Add the Apache lines of code to the vhosts.conf or httpd.conf file for your site. Look for your site in the file and find the line that starts with <Directory> - add the code above into that section and save the file. Reload Apache.


mod_deflate, Enable Gzip Compression on Apache, Use this tutorial to Enable Gzip Compression in Apache Web server on Linux systems. Apache Gzip  When configuring Apache, you can turn on settings like compression in many places. First, there’s a global configuration file (httpd.conf). Next, you can have a.htaccess file in a root directory, which can apply to all subdirectories. Lastly, you can have a.htaccess file in each subdirectory.


How to enable compression and gzip for page speed., Enable compression on Apache webservers. The instructions and code above will work on Apache. If they are not working there is another way  GZip Ninja Speed Compression. This is a fast and easy way to enable Gzip on Apache installations. That’s all it does. It should work on just about any basic WordPress installation, so long as your server is running Apache. It hasn’t been updated in three years, though, so don’t expect support if it doesn’t work for you.


How can I get Apache gzip compression to work?, Try this : #################### # GZIP COMPRESSION # ###############​##### SetOutputFilter DEFLATE AddOutputFilterByType  If your Web Host is through C Panel Enable G ZIP Compression on Apache C Panel. Go to CPanel and check for software tab. Previously Optimize website used to work but now a new option is available i.e "MultiPHP INI Editor". Select the domain name you want to compress. Scroll down to bottom until you find zip output compression and enable it.