How to make your website faster in easy steps
How to make your website faster in easy steps.
How gzip Compression works.
When a request is made by a web browser to your website, Webserver compresses html,css,js,php,txt,pl, etc. and send compress files to users web browser, Then web browser identifies compression and decompress the zip files and displays your website. Which saves bandwidth and l oad website faster.
Enable gzip compression via .htaccess on Apache web servers
The .htaccess file controls many important things for your site.
Create text file and save it with filename .htaccess.
If filename is already present on server then edit and add below rules.
<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 upload in root directory where your code is present and then refresh your webpage.
How to check If gzip compression is working.
In web browser Press F12 Type your website in url box and press enter. In Chrome Click on "Network" option. In Firefox Click on "Net" option. If not enabled, click enable it. Then Check transferred file size. See the difference before and after adding script.
If Above code seem dint work then remove it from .htaccess and add below code.
AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript
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;
Was this article Helpful? [ratings]
If you need more help reply in comments.
Thanks. It works ?