html - How to Add Expires Headers? -
i'm using yslow in safari try , improve website speed, , reported:
grade f on add expires headers there 9 static components without far-future expiration date. (2014/5/29) http://fonts.googleapis.com/css?family=trade+winds (2012/4/15) http://mydomain.com/example.css
what's best practice add expires headers in html? host godaddy, , .htaccess file provide blank.
this i've tried far ...
<ifmodule mod_expires.c> expiresactive on # perhaps better whitelist expires rules? perhaps. expiresdefault "access plus 1 month" # cache.appcache needs re-requests # in ff 3.6 (thx remy ~introducing html5) expiresbytype text/cache-manifest "access plus 0 seconds" # document html expiresbytype text/html "access plus 0 seconds" # data expiresbytype text/xml "access plus 0 seconds" expiresbytype application/xml "access plus 0 seconds" expiresbytype application/json "access plus 0 seconds" # rss feed expiresbytype application/rss+xml "access plus 1 hour" # favicon (cannot renamed) expiresbytype image/x-icon "access plus 1 week" # media: images, video, audio 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" expiresbytype video/ogg "access plus 1 month" expiresbytype audio/ogg "access plus 1 month" expiresbytype video/mp4 "access plus 1 month" expiresbytype video/webm "access plus 1 month" # htc files (css3pie) expiresbytype text/x-component "access plus 1 month" # webfonts expiresbytype font/truetype "access plus 1 month" expiresbytype font/opentype "access plus 1 month" expiresbytype application/x-font-woff "access plus 1 month" expiresbytype image/svg+xml "access plus 1 month" expiresbytype application/vnd.ms-fontobject "access plus 1 month" # css , javascript expiresbytype text/css "access plus 1 year" expiresbytype application/javascript "access plus 1 year" expiresbytype text/javascript "access plus 1 year" <ifmodule mod_headers.c> header append cache-control "public" </ifmodule> </ifmodule>
i figured out on own. solution not depends on host (godaddy in case), type of account have (linux classic, in case) well.
my solution create .htaccess file in root directory of ftp (plaintext) , paste following:
<ifmodule mod_expires.c> # activate mod_expires directory expiresactive on # locally cache common image types 7 days expiresbytype image/jpg "access plus 7 days" expiresbytype image/jpeg "access plus 7 days" expiresbytype image/gif "access plus 7 days" expiresbytype image/png "access plus 7 days" # cache css files 24 hours expiresbytype text/css "access plus 24 hours"
Comments
Post a Comment