1

In my application, I make numerous calls to preload images to brower cache in the background using Loader instances and ignore the complete event. I don't store the results in the application, but rather want to store them in the browser cache. The images have long Expires header dates.

When I want to use a particular image(s), I again use a Loader instance and call the same url and listen for the complete event to load the file to an Image.

The problem is that when I re-request the url for the "cached" image, it is making an http request with response 200 status, which I presume means it is hitting the server.

How do I make sure that a request for a cached image never hits the server from Flex?

In general, I am finding that any request to a url for a cached image (with a long expires header) is making another request to the server, or at least that is my interpretation of it in Firebug.

Any ideas how to do this? Or am I misinterpreting what Firebug is telling me?

Thanks.

4

1 回答 1

0

所以,是的,我误解了萤火虫。事实证明,firebug 记录了 url 请求,它看起来像一个正常的请求。但是,如果您使用像wireshark这样的网络监视器来监控网络,您会注意到缓存图像的 url 没有传出数据包。Flex 确实会加载缓存的图像。

为了确保图像缓存的安全,我添加了以下 Cache-Control 标头(尽管我认为 expires 就足够了。在发布此内容时已经过了一年)。

缓存控制:max-age=31536000,必须重新验证

过期:格林威治标准时间 2011 年 12 月 1 日星期四 16:00:00

因此,如果您正确设置了缓存标头(请注意,如果日期不是 expires 标头中的有效日期,则它不起作用),当您将 url 调用到缓存的图像时,flex 将从缓存中加载。

于 2011-04-05T17:13:21.293 回答