Adding expires header to CSS/JS and image/flash files.
First, Go to your apache’s httpd.conf file
I my case its “C:\xampp\apache\conf\httpd.conf”
The lines beginning with # indicate that these are comments
Remove the comments for these below mentioned lines
Add the below thing to remove the ETags. This can be added at the end
FileETag None
To Add expires header to all the files that are requested from the server
ExpiresActive On
ExpiresDefault "access plus 300 seconds"
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
ExpiresByType text/html "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType application/x-shockwave-flash "access plus 1 day"
Note: Here “myProject” is the folder where
my web pages are present. i.e “C:\xampp\htdocs\myProject”. Where
“webResources” is the directory where my css, js, image, flash files are
present. For all these files I am adding expires header of one day.
Means these files can be can be cached for the entire day in the local
browser. In other words these files are not changed at least for one
day.
To Gzip the CSS and JS files that are present in the “webResources” folder
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary