许多图像即使在缓存时也会延迟 [英] many images delay even when cached

查看:64
本文介绍了许多图像即使在缓存时也会延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,大约有100张图片,每张约10k。

,其中典型的img标签看起来像这样,

< img src =" item001。 JPG"高度= QUOT; 70" ALT ="" onMouseOver =" showPic(this)"

border =" 0">

并非所有图片都需要一次查看,具体取决于哪个类别

选中,任何时候只能看到10张图片。

我通过设置div容器隐藏并显示图像类别

显示:none / block或visibility:hidden / visible。


即使图像缓存在客户端上,当页面加载时,即

它倒计时还有几秒延迟,直到没有剩余

项目。

在firefox中有相同的延迟,但不是倒计时它只是说

''等待......''


据我所知,加载时避免这种延迟的方法不是
到设置图像标签的src直到以后,当图像需要查看(使用javascript)时。

那不是问题,我试过了,它有效,但现在(对于s ome

原因)只要

用户返回网站,浏览器就会忘记图像被缓存,并且必须从服务器下载图像,

第一次查看特定类别的图像。

这个,我认为,这是因为src属性不再是

硬编码了来源,浏览器无法将

缓存中的条目与通过javascript设置的图像的src相关联?


所以它看起来像是唯一的解决方案可能是动态生成html,需要时需要
,src完好无损,或者在需要时使用框架获取html




我在这里遗漏了什么吗?

谢谢。

解决方案

cosmic foo写道:

我有一个页面,大约有100张图片,每张约10k。
其中典型的img标签看起来像这样,
< img src =" item001。 JPG及现状吨;高度= QUOT; 70" ALT ="" onMouseOver =" showPic(this)"
border =" 0">
并非所有图片都需要一次查看,具体取决于选择的类别,仅限于任何时候都可以看到10张图片。
我通过设置div容器来隐藏和显示图像类别
display:none / block或visibility:hidden / visible。

虽然图像缓存在客户端上,但当页面加载时,
仍然有几秒钟的延迟,而它倒计时直到没有剩余的
项目。
在Firefox中有同样的延迟,但不是倒计时只是说
''等待......''

根据我的理解,加载时解决这个延迟的方法不是
设置图像标签的src直到以后,当需要查看图像时(使用javascript)。
这不是问题而且我已经尝试过了,它有效,但是现在(出于某些原因)浏览器忘记了图像已被缓存w每当
用户返回网站,并且必须从服务器下载图像时,第一次查看特定类别的图像。
我认为这是因为src属性不再在源代码中进行硬编码,浏览器无法将
缓存中的条目与通过javascript设置的图像的src相关联?

因此,看起来唯一的解决方案可能是动态生成html,
需要时,src完好无损,或者在需要时使用框架获取html
。 />
我在这里错过了什么?
谢谢。



您可以尝试使用css方法进行预加载吗?:

http://www.ilovejackdaniels.com/css /...ages-with-css/




" Jedi Fans" <"新闻[在] jedifans [ - =点== - ] COM">在留言中写道

news:42 ********** @ mk-nntp-2.news.uk.tiscali.com ...

cosmic foo写道:

我有一个页面,大约有100张图片,每张约10k。
其中典型的img标签看起来像这样,
< img src =" item001。 JPG"高度= QUOT; 70" ALT ="" onMouseOver =" showPic(this)"
border =" 0">
并非所有图片都需要一次查看,具体取决于选择的
类别,任何时候都可以看到10张图片。
我通过设置div容器来隐藏和显示图像类别
display:none / block或visibility:hidden / visible。

虽然图像缓存在客户端上,但当页面加载
时,仍有几秒延迟,而它倒计时直到有
没有剩余项目。
在Firefox中有相同的延迟,但不是倒计时只是
说''等待......''

根据我的理解,加载时绕过这个延迟的方法是
不要将图像标签的src设置到以后,当需要查看图像时(使用javascript)。
这不是问题而且我已经尝试过了,它可以工作,但是现在(因为某些原因,因为
)浏览器忘记了图像已被缓存了r
用户返回该站点,并且必须从
服务器下载图像,这是第一次查看特定类别的图像。
我认为这是因为src属性不再在源代码中进行硬编码,浏览器无法将缓存
中的条目与通过javascript设置的图像的src相关联?

因此,看起来唯一的解决方案可能是在
fly上生成html,在需要时,src完好无损,或者在需要时使用框架获取html
。 />
我在这里遗漏了什么吗?
谢谢。


你可以尝试使用css方法进行预加载吗?:

http://www.ilovejackdaniels.com/css / ... age-with-css /




谢谢,但这不会只是在页面加载时保留延迟,这我就是b $ b我试图避免?

如果显示:none会导致图像无法加载,直到它将
更改为显示:block。

要么是如果有一些方法来设置图像的src使用

javascript并且当你返回网站时仍然将它缓存



cosmic foo写道:

" Jedi Fans" <"新闻[在] jedifans [ - =点== - ] COM">在消息中写道
新闻:42 ********** @ mk-nntp-2.news.uk.tiscali.com ...

cosmic foo写道:< blockquote class =post_quotes>我有一个页面,大约有100张图片,每张约10k。
其中典型的img标签看起来像这样,
< img src =" item001.jpg"高度= QUOT; 70" ALT ="" onMouseOver =" showPic(this)"
border =" 0">
并非所有图片都需要一次查看,具体取决于所选的类别,只能看到约10张图片在任何时候。
我通过设置div容器隐藏和显示图像类别
显示:无/块或可见性:隐藏/可见。

即使图像是缓存在客户端上,当页面加载时,即,在倒计时仍有几秒延迟,直到没有剩余项目为止。
在Firefox中有相同的延迟,但不是倒计时它只是说' '等待......''

根据我的理解,加载时绕过这个延迟的方法不是设置图像标签的src,直到以后,当图像需要
查看(使用javascript)。
这不是问题而且我已经尝试过了,它可以工作,但现在(出于某种原因)浏览器忘记了每当用户返回时图像都被缓存网站,并且必须从服务器下载图像,第一次查看特定类别的图像。
我认为这是因为src属性不再在源代码中进行硬编码,浏览器无法将缓存中的条目与通过javascript设置的图像的src相关联?

所以看起来唯一的解决方案可能是动态生成html,当它需要,src完好无损,或者在需要时使用框架来获取html

我在这里错过了什么?
谢谢。


你可以尝试使用css方法进行预加载吗?:

http://www.ilovejackdaniels.com/css/...ages-with-css/



谢谢但是这不会只是在页面加载时保留延迟,这是我试图避免的吗?
如果显示:没有引起图像会有什么好处不要加载,直到它被改为显示:阻止。
要么是否有某种方法使用
javascript设置图像的src并仍然将其缓存
当你回到网站时。



不确定lol,对不起


I have a page with about 100 images of about 10k each.
where a typical img tag looks like this,
<img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)"
border="0">
Not all the images need to be viewed at once, depending on what category is
selected, only about 10 images are seen at any one time.
I hide and show categories of images by setting a div container
display:none/block or visibility:hidden/visible.

Even though the images are cached on the client, when the page loads in ie,
there is still a few seconds delay while it counts down until there are no
items remaining.
In firefox there is the same delay but instead of counting down it just says
''waiting for..''

From what i understand, the way to get around this delay when loading is not
to set the src of the image tags until later, when the images need to be
viewed (using javascript).
That''s not a problem and i have tried it, and it works, but now (for some
reason) the browser forgets that the images have been cached whenever the
user returns to the site, and has to download the images from the server,
the first time a particular category of images is viewed.
This, i presume, is happening because the src attribute is no longer
hard-coded in the source, and the browser cannot associate an entry in the
cache with the src of an image that is set via javascript?

So it looks like the only solution may be to generate the html on the fly,
when it is needed, with the src intact, or to use frames to get the html
when it is needed.

Am i missing something here?
Thanks.

解决方案

cosmic foo wrote:

I have a page with about 100 images of about 10k each.
where a typical img tag looks like this,
<img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)"
border="0">
Not all the images need to be viewed at once, depending on what category is
selected, only about 10 images are seen at any one time.
I hide and show categories of images by setting a div container
display:none/block or visibility:hidden/visible.

Even though the images are cached on the client, when the page loads in ie,
there is still a few seconds delay while it counts down until there are no
items remaining.
In firefox there is the same delay but instead of counting down it just says
''waiting for..''

From what i understand, the way to get around this delay when loading is not
to set the src of the image tags until later, when the images need to be
viewed (using javascript).
That''s not a problem and i have tried it, and it works, but now (for some
reason) the browser forgets that the images have been cached whenever the
user returns to the site, and has to download the images from the server,
the first time a particular category of images is viewed.
This, i presume, is happening because the src attribute is no longer
hard-coded in the source, and the browser cannot associate an entry in the
cache with the src of an image that is set via javascript?

So it looks like the only solution may be to generate the html on the fly,
when it is needed, with the src intact, or to use frames to get the html
when it is needed.

Am i missing something here?
Thanks.


you could try a css method for preloading?:

http://www.ilovejackdaniels.com/css/...ages-with-css/



"Jedi Fans" <"news[at]jedifans[--=dot==-]com"> wrote in message
news:42**********@mk-nntp-2.news.uk.tiscali.com...

cosmic foo wrote:

I have a page with about 100 images of about 10k each.
where a typical img tag looks like this,
<img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)"
border="0">
Not all the images need to be viewed at once, depending on what category is selected, only about 10 images are seen at any one time.
I hide and show categories of images by setting a div container
display:none/block or visibility:hidden/visible.

Even though the images are cached on the client, when the page loads in ie, there is still a few seconds delay while it counts down until there are no items remaining.
In firefox there is the same delay but instead of counting down it just says ''waiting for..''

From what i understand, the way to get around this delay when loading is not to set the src of the image tags until later, when the images need to be
viewed (using javascript).
That''s not a problem and i have tried it, and it works, but now (for some reason) the browser forgets that the images have been cached whenever the user returns to the site, and has to download the images from the server, the first time a particular category of images is viewed.
This, i presume, is happening because the src attribute is no longer
hard-coded in the source, and the browser cannot associate an entry in the cache with the src of an image that is set via javascript?

So it looks like the only solution may be to generate the html on the fly, when it is needed, with the src intact, or to use frames to get the html
when it is needed.

Am i missing something here?
Thanks.


you could try a css method for preloading?:

http://www.ilovejackdaniels.com/css/...ages-with-css/



Thanks but wouldn''t that just retain the delay when the page loads, which i
am trying to avoid?
What would be great is if display:none caused an image not to load until it
was changed to display:block.
Either that or if there was some way to set the src of an image using
javascript and still have it cached
when you return to the site.


cosmic foo wrote:

"Jedi Fans" <"news[at]jedifans[--=dot==-]com"> wrote in message
news:42**********@mk-nntp-2.news.uk.tiscali.com...

cosmic foo wrote:

I have a page with about 100 images of about 10k each.
where a typical img tag looks like this,
<img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)"
border="0">
Not all the images need to be viewed at once, depending on what category is selected, only about 10 images are seen at any one time.
I hide and show categories of images by setting a div container
display:none/block or visibility:hidden/visible.

Even though the images are cached on the client, when the page loads in ie, there is still a few seconds delay while it counts down until there are no items remaining.
In firefox there is the same delay but instead of counting down it just says ''waiting for..''

From what i understand, the way to get around this delay when loading is not to set the src of the image tags until later, when the images need to be
viewed (using javascript).
That''s not a problem and i have tried it, and it works, but now (for some reason) the browser forgets that the images have been cached whenever the user returns to the site, and has to download the images from the server, the first time a particular category of images is viewed.
This, i presume, is happening because the src attribute is no longer
hard-coded in the source, and the browser cannot associate an entry in the cache with the src of an image that is set via javascript?

So it looks like the only solution may be to generate the html on the fly, when it is needed, with the src intact, or to use frames to get the html
when it is needed.

Am i missing something here?
Thanks.


you could try a css method for preloading?:

http://www.ilovejackdaniels.com/css/...ages-with-css/



Thanks but wouldn''t that just retain the delay when the page loads, which i
am trying to avoid?
What would be great is if display:none caused an image not to load until it
was changed to display:block.
Either that or if there was some way to set the src of an image using
javascript and still have it cached
when you return to the site.


not sure lol, sorry


这篇关于许多图像即使在缓存时也会延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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