How to enable gzip compression on my website

Issue

  • Gzip compression wordpress
  • SEO recommends to enable gzip compression on web contents.
  • Enable gzip on your website to improve the Page Speed Grade on gtmetrix.com and load time on webpagetest.org
  • How do i enable gzip without root access to the server ?
  • How do i enable gzip with .htaccess rules.
  • How do i enable gzip compression on my wordpress / joomla / django website.

Environment

  • Websites running on Apache web-server.
  • All shared hosting accounts.

Solution

Add the following content to your .htaccess File.

# Gzip Start
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary: Accept-Encoding
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
Header append Vary User-Agent env=!dont-vary
</FilesMatch>
# Gzip End

Now go to gtmetrix.com and test your site. You should see 100% gzip compression.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top