图像预加载不适用于 FireFox 中的图像

发布于 2024-08-14 09:42:58 字数 494 浏览 8 评论 0原文

我正在动态切换背景图像。当然,它们需要预加载才能及时显示。我正在预加载它们,我能够在图像加载时在 FireBug 中进行跟踪。当背景图像切换时,我看到图像在 FireBug 中再次下载。

这是我的网址: http://www.morganpackard.com/siteRoot/

奇怪的是,如果我重新加载页面,一切都按预期进行。我采取的步骤如下:

1)清除FireFox缓存 2)重新加载页面 图像加载缓慢,并且显然既没有预加载也没有缓存。每次进行图像交换时,都会再次下载图像。 3)现在再次重新加载页面而不清除缓存 图像立即加载和交换,一切都按预期进行。

所以看起来我必须在 FireFox 从缓存中读取图像之前重新加载。这很奇怪。有什么想法吗?

注意:我的图像很大。当然,我会压缩它们,但希望首先对预加载进行排序。

I'm dynamically switching background images. Naturally, they need to be preloaded to display promptly. I am preloading them, am able to following in FireBug as the images load. When the background image switches, I see the images download again in FireBug.

Here's my url: http://www.morganpackard.com/siteRoot/

Strangely, if I reload the page, everything works as expected. The steps I'm taking are as follows:

1) clear FireFox cache
2) reload page
Images load slowly, and, apparently are neither being preloaded nor cached. Every time there's an image swap, the image downloads again.
3) now reload the page again without clearing the cache
Images load and swap instantly, everything works as expected.

So it looks like I'm having to RELOAD before FireFox will read images from the cache. This is kooky. Any ideas?

Note: My images are ENORMOUS. I'll compress them, of course, but want to get this preloading this sorted first.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜中书 2024-08-21 09:42:58

我没有阅读你的代码,但是为了使预加载工作,你必须将图像添加到文档 DOM 中,否则它可能会被积极地垃圾收集。

I didn't read your code, but for preloading to work, you must add the image to the document DOM, otherwise it can be garbage collected aggressively.

⒈起吃苦の倖褔 2024-08-21 09:42:58

通过 HttpFox 检查,在初始加载后,我没有看到更多的 http 请求 - 当单击周围时 - 对于您的背景图像。如果我点击“刷新”,则会重新加载图像。我认为这是正确的,也是您所期望的。但是请注意,页面刷新时重新加载页面及其资产(例如图像、CSS 等)取决于响应标头以及浏览器/插件工具中指定的这些内容的任何覆盖。看一下 pragma: no-cache 和 W3C Cache-Control (第 14.9 节)

编辑:在 Firebug 开启的情况下,当我单击周围时,我看到重新加载。这大概是 Firebug 的产物。关闭萤火虫,你就不会重新加载。

Checking with HttpFox, I am not seeing further http requests - when clicking around - for your background images after the initial load. If I hit "refresh" then the images are reloaded. I think this is correct and what you'd expect. However be aware that reloading of a page and its assets like images, css etc on a page refresh is dependent on both response headers and any over-rides for these specified in your browser/plugin tools. Take a look at pragma: no-cache and W3C Cache-Control (Section 14.9)

Edit: With firebug on, I am seeing reloads when I click around. This is presumably an artefact of Firebug. Turn off firebug and you wont have the reloads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文