Enable GZIP Compression to speed up your website
Page Visited: 2567
What is GZIP Compression
Compression is an act of reducing file size sent from your hosting server. Compression allows your web server to provide smaller file size that can speed up your website loading time upto 70% and it saves at least 50% of your bandwidth usage.
GZIP Compression is recommended for following type of files
- Static HTML (such .html, .htm)
- Dynamic HTML (such as extension .php, .aspx)
- Textfiles (extension .txt)
- Layout & Script Files (such as extension .css and .js)
- Webservices, Files (such as WSDL, REST and JSON)
GZIP compression is not recommended for non-text files, such as media or graphical files because it is not save much space when compressing.
Importance of GZIP Compression
Enabling compression is very much important in today’s web world. If you are not using compression means you are losing your visitors because due to slower page speed your competitors get more visitors if they have enabled compression. All large websites worldwide use GZIP Compression.
How Compression Works on Web
When a user (client browser) requests a page on a webserver, it compresses (zip) textfiles and sends the files to client browser. Client browser automatically unzips files and serves the user much faster. All modern browsers understand and accept compressed files.
When a browser visits a webserver it checks to see if it's enabled it receives the gzip file which is significantly smaller and if it is not, then it still receives the normal page.
How to Enable GZIP Compression
First you check either compression is installed on your hosting server or not (assuming your host server using apache you'll need the mod_gzip.c OR mod_deflate.c modules installed, or you can check with phpinfo(); function)
Compression can be enabled by configuring your webserver.
- Each web servers has its own setting for enabling configuration
- Here are the most common ways to enable compression
For Apache Web Server
In apache web server, there are two modules (mod_gzip.c or mod_deflate.c) to enable GZIP compression. Below mention code give you an example of mod_deflate. You will need to add the following lines of code to your .htaccess file
#compress all text & html: AddOutputFilterByType DEFLATE text/html text/plain text/xml
# Or, compress certain file types by extension: <Files *.html> SetOutputFilter DEFLATE </Files>
Save the .htaccess file and then refresh your webpage. Check either compression is working properly visit www.checkgzipcompression.com Enter your website address and test if your web server is GZIP enabled.
In IIS, you can set up compression by setting server properties.
Go to "website properties" (Tab Services), and then allow "compress application files".