Enabling GZIP compression using htaccess

Enabling GZIP compression can help you reduce the size of your webpage, which can reduce the amount of time to download the resource of webpage, reduce data usage for the client and improve webpage speed.

What is GZIP Compression?

GZIP simply is a file format and used for file compression and decompression. GZIP compression is enabled server-side, and allows user to reduce the file size of your HTML, stylesheets, and JavaScript files. It will not work on images as these are already compressed in a different way but we can enable cache to reduce webpage size for return users . Using enabling GZIP file compression we can reduce up to 70% file size. It is easiest way to optimizations of webpage.

How to Enable GZIP Compression

Here i am enabling GZIP Compression using htaccess file, this code will be enable GZIP and cache of webpage but here i am not setting expiry date of cache file for use it copy and past into htaccess file.

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Enable GZIP Compression With Expiry Date

Here i am enabling GZIP Compression using htaccess file, this code will be enable GZIP and cache of webpage with expiry date of cache file for use it copy and past into htaccess file.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 11 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresDefault "access plus 2 days"
</IfModule>

Note : Don’t set expiry date for long term because of if you set cache expiry date 1 year then you made changes in css file or website design then for return user not visible your latest version or design of website.

Leave a Reply

Related Posts: You may like

How to disable selection of text on a web page

Google Geochart show list of all countries with multiple colors

List of companies and their Headquarters And CEOs in the world

List of Top 15 Popular Search Engines

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.