.htaccess - Add Expires headers on Yslow doesn't have any effect -
i have mod_expires , mod_headers enabled on server , code in htaccess:
<filesmatch "\.(htm|html|xhtml|css|js|php)$"> adddefaultcharset utf-8 header set content-language "en-us" </filesmatch> <ifmodule mod_headers.c> header set vary "accept-encoding" </ifmodule> php_value session.cookie_domain "www.domain.com" options -indexes # year <filesmatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$"> header set cache-control "public" header set expires "thu, 15 apr 2010 20:00:00 gmt" header unset last-modified </filesmatch> #2 hours <filesmatch "\.(html|htm|xml|txt|xsl)$"> header set cache-control "max-age=7200, must-revalidate" </filesmatch> <filesmatch "\.(js|css)$"> setoutputfilter deflate header set expires "thu, 15 apr 2010 20:00:00 gmt" </filesmatch> <filesmatch ".(eot|ttf|otf|woff)"> <ifmodule mod_headers.c> header set access-control-allow-origin "*.domain.com" </ifmodule> </filesmatch> <ifmodule mod_deflate.c> # force deflate mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ <ifmodule mod_setenvif.c> <ifmodule mod_headers.c> setenvifnocase ^(accept-encodxng|x-cept-encoding|x{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[x~-]{4,13}$ have_accept-encoding requestheader append accept-encoding "gzip,deflate" env=have_accept-encoding </ifmodule> </ifmodule> # compress output labeled 1 of following mime-types # (for apache versions below 2.3.7, don't need enable `mod_filter` # , can remove `<ifmodule mod_filter.c>` , `</ifmodule>` lines # `addoutputfilterbytype` still in core directives) <ifmodule mod_filter.c> addoutputfilterbytype deflate application/atom+xml \ application/javascript \ application/json \ application/rss+xml \ application/vnd.ms-fontobject \ application/x-font-ttf \ application/xhtml+xml \ application/xml \ font/opentype \ image/svg+xml \ image/x-icon \ text/css \ text/html \ text/plain \ text/x-component \ text/xml </ifmodule> </ifmodule> options +followsymlinks rewriteengine on <ifmodule mod_headers.c> header unset etag </ifmodule> fileetag none <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" # favicon (cannot renamed) expiresbytype image/x-icon "access plus 1 month" # media: 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" # 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 month" expiresbytype application/javascript "access plus 1 month" expiresbytype text/javascript "access plus 1 month" <ifmodule mod_headers.c> header append cache-control "public" </ifmodule> </ifmodule>
in gtmatrix in google pagespeed have 100% on yslow "add expires headers" 0. i've tried can't seem make yslow work. can help? thanks.
you're setting expiration in past, means expire straight away. idea behind adding expires headers tell browser doesn't need make http request @ resource until date in future, instead should use cached copy.
probably idea use on assets know not going change. if end changing asset future expires date you'll need change url (which can adding query string on end blah.css?1234.
also check expires headers coming through in response headers of assets inspecting them web inspector.
Comments
Post a Comment