要求更好地解释过期标题

然而,我已经成功实施了expires头文件,好几天我都被一件事情搞砸了。 这篇文章: http : //www.tipsandtricks-hq.com/how-to-add-far-future-expires-headers-to-your-wordpress-site-1533 states

请记住,当你使用expires头时,文件被caching在浏览器中,直到它过期,所以不要在经常改变的文件上使用它。

其他网站在我的阅读中也一样。 但是这似乎并不真实。 我更新了一个图像,使用相同的名称,几次。 每次更新和刷新我的浏览器时,都会显示新的图像(具有相同的名称)。 我从这篇文章中明白,除非我使用新的名字,否则应该显示旧的图像。

你碰巧知道误会在哪里?

我已经validation,有问题的图像已过期设置在其上的标题:

请求标题:

Host domain.com User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28 FirePHP/0.5 Accept image/png,image/*;q=0.8,*/*;q=0.5 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Connection keep-alive Referer http://domain.com/index.php Cookie __utma=1.61479883.1332439113.1332783348.1332796726.4; __utmz=1.1332439113.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);PHPSESSID=lv2hun9klt2nhrdkdbqt8abug7; __utmb=1.33.10.1332796726; __utmc=1; ck_authorized=true x-insight activate If-Modified-Since Mon, 26 Mar 2012 21:55:33 GMT Cache-Control max-age=0 

响应标题:

 Date Mon, 26 Mar 2012 22:06:50 GMT Server Apache/2.2.3 (CentOS) Connection close Expires Wed, 25 Apr 2012 22:06:50 GMT Cache-Control max-age=2592000 

相关configuration(.htaccess):

 <IfModule mod_expires.c> # Enable Expires Headers for this directory and sub directories that don't override it ExpiresActive on # Set default expiration for all files ExpiresDefault "access plus 24 hours" # Add Proper MIME-Type for Favicon AddType image/x-icon .ico # Set specific expriation by file type ExpiresByType application/javascript "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/x-icon "access plus 1 month" ExpiresByType image/ico "access plus 1 month" ExpiresByType image/icon "access plus 1 month" </IfModule> 

保持caching的图像和使用caching的图像看起来很混乱。 浏览器保存已configuration的caching图像。 但是,如果浏览器知道它不是最新的,它将不会使用caching的图像。 重新validation和到期是两件不同的事情。

你应该使用“Cache-Control max-age = 2592000,public”,所以浏览器会保存文件。