Set up expire header in apache using htaccess file

Setup expire header for images, javascript files, css style sheet in PHP


We can setup expire header for all the images, javascript file, css style sheet, using htaccess file. This can be done by including the following code into your .htaccess file.


#Expire headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000 #for all js file
ExpiresByType text/css A2592000 # for css files
ExpiresByType image/gif A2592000 #gif images
ExpiresByType image/png A2592000 # png images
ExpiresByType image/jpeg A2592000
ExpiresByType text/plain A2592000
ExpiresByType text/js A2592000
ExpiresByType application/x-shockwave-flash A2592000
ExpiresByType video/x-flv A2592000
ExpiresByType application/pdf A2592000
ExpiresByType text/html A600
</IfModule>

A2592000 = 720hours = 30days
A3600=1 hour: (60*60);


Related Topic Setting Expire Header for PHP pages
What is Redirection and their Types
Apache mod_rewrite Module Examples
Apache AddType directive
How to Enable Rewrite Module on xampp apache2

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback