PDA

View Full Version : How to tell browser to cache images and other content?



Fli
02-21-2014, 11:42 AM
Hello,

the tools (http://internetlifeforum.com/general-webmaster-discussion/1454-how-minimize-load-time-any-website/#post2151) which helps discover slow elements on website suggested me to add/set "Expire headers (http://gtmetrix.com/add-expires-headers.html)" into .htaccess file.

example:


<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 month"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 month"
</IfModule>


Also i have these from past in my .htaccess



# ETAG - By removing the ETag header, you disable caches and browsers from being able to validate files
Header unset ETag
FileETag None

# 30 DAYS
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>

# 2 HOURS
<filesMatch ".(html|htm|html|xml|txt)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>

# 2 HOURS
<filesMatch ".(php)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>


So im curious how these two differentiate? And if its really influence webrowsers like Google Chrome in its default state, if really webmaster can save bandwidth?