在 Yslow 上添加过期标头没有任何影响



我在服务器上启用了mod_expires和mod_headers,这段代码在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 for 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 all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines as
# `AddOutputFilterByType` is still in the 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 to 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"
# Your 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 be 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 and 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>

在GTmatrix在谷歌页面速度我有100%,但在缓慢的"添加过期头"是0。我已经尝试了所有的方法,但我似乎无法使慢速工作。有人能帮忙吗?谢谢。

您将过期时间设置为过去,这意味着它们立即过期。添加expires报头背后的想法是,你告诉浏览器,它甚至不需要为这个资源发出http请求,直到未来的某个日期,它应该只使用缓存的副本。

可能只有在你知道不会改变的资产上使用它才是一个好主意。如果你最终改变了一个未来到期日期的资产,你需要改变它的url(你可以在最后添加一个查询字符串,如blah.css?1234.

)。

也检查过期头肯定是通过资产的响应头通过检查他们与您的web检查。

相关内容

  • 没有找到相关文章

最新更新