After you host your site, check the speed of your site in google insights page speed. You may be get less speed for your site if your information is not compressed. Mostly all sever can compress the files before send it to download. If the server didn't do this, you have to do compress your file. It can be done by .htaccess.
Example:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
</IfModule>
Explanation:
Where,
mod_deflate.c provides the output filter ' DEFLATE ' which is used to compress the file in your browser before send it to download.
<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>
You can also done by your php file. Just add this to your header file.
<?php
if(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')) ob_start('ob_gzhandler');
else
ob_start();
?>
After add this content to your .htaccess file, you can check whether your site is compressed or not in website.
Related Post:
Enable compression using mod_deflate() in .htaccess:
Gzip is a server process that compress your files on fly before transmission to the user. It is used to compress text files like html, css and javascript. It reduces the visitor time and your bandwidth. Due to compression, the speed of your site will be increased.Example:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
</IfModule>
Explanation:
Where,
mod_deflate.c provides the output filter ' DEFLATE ' which is used to compress the file in your browser before send it to download.
Enable compression using mod_gzip() in .htaccess:
<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>
You can also done by your php file. Just add this to your header file.
<?php
if(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')) ob_start('ob_gzhandler');
else
ob_start();
?>
After add this content to your .htaccess file, you can check whether your site is compressed or not in website.
Related Post:
What is htaccess?
Restrict users to access pages from site using .htaccess
How to create error document using .htaccess
How to add expires headers using .htaccess
How to add MIME types using .htaccess
How to enable SSI using .htaccess
How to force script to display as source code using .htaccess
How to prevent access to php.ini file using .htaccess
How to enable or disable directory list using .htaccess
How to redirect urls using .htaccess
How to redirect to www using .htaccess
How to enable short tag in php using .htaccess
How to access pages through one page in site using .htaccess
Restrict users to access pages from site using .htaccess
How to create error document using .htaccess
How to add expires headers using .htaccess
How to add MIME types using .htaccess
How to enable SSI using .htaccess
How to force script to display as source code using .htaccess
How to prevent access to php.ini file using .htaccess
How to enable or disable directory list using .htaccess
How to redirect urls using .htaccess
How to redirect to www using .htaccess
How to enable short tag in php using .htaccess
How to access pages through one page in site using .htaccess
What is the difference between the mod_gzip and mod_deflate
ReplyDeleteActually the Apache supports several level compression using by mod_deflate and mod_gzip. The mod_deflate is easy to compressed and actively. There is no lose of data when you compress the files using mod_deflate. It use all in its memory. It doesn't use temporary memories.
DeleteThe mod_gzip is compressed the textual file. When it compress the files, it maintain its MIME types.
thank you
ReplyDelete