为什么Firefox看起来不是缓存图像? [英] Why does firefox not appear to be caching images?

查看:163
本文介绍了为什么Firefox看起来不是缓存图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:下面提供了答案。

我已经挣扎了几天,理解Mozilla Firefox为什么不能从其缓存中检索图像,而不是每次我重新加载一个页面时都会获取新的副本。



谷歌浏览器似乎没有这个问题,但这是因为在Chrome中刷新页面并不会强制它重新加载图像(除非使用了CTRL-F5)。



下面我回答了我自己的问题,并添加了一些额外的信息,希望能够帮助别人节省时间解决方案

感谢kapep,很好的建议。不知道如何将短语作为一个问题 - 但回答我自己的问题,我可以做!

首先为了确保图像是可缓存的,您必须检查响应头以确保将以下标题设置为有效值:


  • 'Cache-Control'设置为private或public。

  • 过期是以将来正确格式的日期。 (例如,星期四,2012年6月21日06:20:49 GMT)

  • 'Last-Modified'不是比'Date'标题更新的。

  • Content-Disposition未设置为attachment;



如果您确信标题设置正确,它仍然看起来像图像不是从缓存到达,请确保以下内容:


  • 您不是F5刷新页面检查缓存作为Firefox将获取图像的新副本,如果刷新。确保您正在重新载入您的页面,方法是导航到另一个页面并重新访问同一页面(这是您的一个用户的正常行为)。
  • 在about:config(只是键入这在你的地址栏访问隐藏的设置)browser.cache.memory.enable = true和browser.cache.disk.enable = true


EDIT: Answer provided below.

I've struggled for a couple of days to understand why Mozilla Firefox continually failed to retrieve images from its' cache as opposed to fetching new copies everytime I reloaded a page.

Google Chrome didn't appear to have this issue, but that's because refreshing the page in Chrome does NOT force it to reload images (unless a CTRL-F5 is used).

Below I've answered my own question and added some extra info that I hope will save someone else some time in getting their head around this issue.

解决方案

Thanks kapep, good advice. Wasn't sure how to phrase as a question - but answering my own question I can do!

First of all to ensure an image IS cacheable you must inspect the Response Headers to ensure the following headers are set to valid values:

  • 'Cache-Control' is set to private or public.
  • 'Expires' is a date in the correct format that is in the future. (eg. Thu, 21 Jun 2012 06:20:49 GMT)
  • 'Last-Modified' is not more recent than the 'Date' header.
  • 'Content-Disposition' is not set to "attachment;"

If you're convinced the headers are set correctly and it still seems like the images aren't arriving from the cache, ensure the following:

  • You are NOT F5 refreshing the page to check for caching as firefox will fetch new copies of the images if you refresh. Ensure you are reloading your page by navigating to another page and re-visiting the same page (as would be normal behaviour by one of your users).
  • In your about:config (just type this in your address bar to access hidden settings) browser.cache.memory.enable = true and browser.cache.disk.enable = true

这篇关于为什么Firefox看起来不是缓存图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆