How .htaccess file helps your website ?
This is the file located in root of your website. Which tells browsers for various rules. One of the common use is Cache control. In which we define rules and it tells same to browsers to cache media files as defined.How to use cache control using .htaccess ?
1. Log on to your web server using any FTP program.2. Find .htaccess in your website's root. (If it's not there make a new one.)
3. Edit it and add below code at the end of the file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## EXPIRES CACHING ## | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/jpg "access 1 year" | |
ExpiresByType image/jpeg "access 1 year" | |
ExpiresByType image/gif "access 1 year" | |
ExpiresByType image/png "access 1 year" | |
ExpiresByType text/css "access 1 month" | |
ExpiresByType application/pdf "access 1 month" | |
ExpiresByType text/x-javascript "access 1 month" | |
ExpiresByType application/x-shockwave-flash "access 1 month" | |
ExpiresByType image/x-icon "access 1 year" | |
ExpiresDefault "access 2 days" | |
</IfModule> | |
## EXPIRES CACHING ## |
In this code you can modify how long you want to cache that files in your users browsers.
don't hesitate to ask your questions in comments below.
Enjoy...!!!
(via LimeCanvas)