Why use gzip to compress your webpages?
Compressing your HTML and CSS files with gzip typically saves around 50 to 70 percent of the file size. This means that it takes less time to load your pages, and it also means less bandwidth is used over all. It is pretty much the standard now and if you are not using it for some reason, your webpages are slower than your competitors.
How to enable Gzip on your website
Compression is enabled by adding some code to a file called .htaccess on your web host/server. This means going to the file manager (or wherever you go to add or upload files) on your webhost. The .htaccess file controls many important things for your site. If you are not familiar with the .htaccess file, please read my
working with .htaccess article to get some know how before changing it.
The code below should be added to your .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>
Save the .htaccess file and then refresh your webpage.What does this do?
Adding this code to your .htaccess file will enable Gzip compression for the most commonly gzipped files and will help your webpages load faster. This not only helps your web page speed, but it also reduces your bandwidth so those who are paying for bandwidth can save real money by doing this.
Enable compression on Apache webservers
The instructions above will work on Apache.
Enable compression on NGINX webservers
To enable compression in NGINX you will need to add the following code to your config file
gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";
# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
gzip_vary on;
Enable compression on Litespeed webservers
The ideal way to enable compression in Litespeed is to do it through the configuration under "tuning". Just go down to "enable compression" and check to see if it is on, if not click "edit" then choose to turn it on. While you are there, look over the several Gzip options that are nearby. The resource covering this
is here.
Source: feedthebot.com
Artikel keren lainnya:
Belum ada tanggapan untuk "How to Enable Gzip Compression"
Posting Komentar