Most of modern Linux distributions contain Apache 2.x web server with the set of standard modules. One of these modules is mod_expires that allows to configure content expiration in local browser cache or caching proxies. Proper configuration for it can significantly improve overall server performance and reduce bandwidth consumption.
I was adjusting mod_expires settings using YSlow extension site grade recommendation on various sites.
Here is what I am using right now
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" ExpiresByType image/gif "access plus 1 week" ExpiresByType image/jpeg "access plus 1 week" ExpiresByType image/png "access plus 1 week" ExpiresByType image/x-icon "access plus 1 week" ExpiresByType image/vnd.microsoft.icon "access plus 1 week" ExpiresByType application/x-javascript "access plus 1 week" ExpiresByType application/pdf "access plus 1 week" ExpiresByType text/css "access plus 1 week" ExpiresByType text/javascript "access plus 1 week" ExpiresByType application/x-shockwave-flash "access plus 1 day" ExpiresByType application/font-woff "access plus 1 week" ExpiresByType application/mp4 "access plus 1 week" ExpiresByType vide/x-flv "access plus 1 week" <FilesMatch "\.(php|php4)$"> ExpiresByType text/html "now" </FilesMatch> </IfModule> <FilesMatch "\.(htm|html|png|gif|jpe?g|jpg|swf|ico|css|js|woff|flv|avi|mp4|pdf)$"> FileETag None <IfModule mod_headers.c> Header unset ETag Header unset Cookie Header unset Set-Cookie Header append Cache-Control "public, no-transform" </IfModule> </FilesMatch> |
In case of problems you might want to remove “js” from FilesMatch expression.
Updated on July 10 2014:
– Modified ExpiresDefault to have baseline expiration relatively high
– Added flv and mp4 ExpiresByType
– Added “no-transform” to Cache-Control header to imporve compatibility with CDN
0 Comments.