最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is Firebug always correct at how it lists downloads with the Net tab? - Stack Overflow

programmeradmin10浏览0评论

Is it possible Firebug may be incorrectly adding downloads to the Net tab when things may be loaded from the cache?

I have some code in a Javascript gallery which is meant to lazily download an image when the thumbnail is clicked and then display it once downloaded. It is meant to determine if it's been downloaded already first (via an array with Boolean values), and if it has been downloaded before, simply display from cache.

I thought it was working fine for a while (because of the speed at which they would appear when clicked twice), but I recently looked into Firebug's Net tab and it seems to be downloading the large image every time (and the total file size gets bigger with every click).

I'm not sure what I have done wrong as a bit of debugging has informed me the Boolean values are being updated correctly.

So my question is, could Firebug be incorrect (I doubt it), or is there any way I can force it to display from cache (I thought using the exact same path to the image for the image.src would do this)

This was my first venture into objects in Javascript so I'm not 100% confident about my code so please be kind!

Is it possible Firebug may be incorrectly adding downloads to the Net tab when things may be loaded from the cache?

I have some code in a Javascript gallery which is meant to lazily download an image when the thumbnail is clicked and then display it once downloaded. It is meant to determine if it's been downloaded already first (via an array with Boolean values), and if it has been downloaded before, simply display from cache.

I thought it was working fine for a while (because of the speed at which they would appear when clicked twice), but I recently looked into Firebug's Net tab and it seems to be downloading the large image every time (and the total file size gets bigger with every click).

I'm not sure what I have done wrong as a bit of debugging has informed me the Boolean values are being updated correctly.

So my question is, could Firebug be incorrect (I doubt it), or is there any way I can force it to display from cache (I thought using the exact same path to the image for the image.src would do this)

This was my first venture into objects in Javascript so I'm not 100% confident about my code so please be kind!

Share Improve this question edited Mar 28, 2012 at 22:57 alex asked Dec 9, 2008 at 4:38 alexalex 491k204 gold badges889 silver badges991 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

The image appearing in the net tab in firebug does not mean it is downloaded from the server. Check the HTTP response code that firebug reports for the image - for me after one visit, it kept returning "304 - Not Modified" which means it is being loaded from the cache.

You can avoid the extra HTTP request that checks if the cache is still fresh by sendingfar-future headers for ponents you want to cache hard. Bear in mind though, that in order to force the client to re-download a ponent that was cached this way you'll have to change the filename.

Firebug might not be 100% correct, or at least, that might not be exactly what would be happening if Firebug was turned off.

I would try using Fiddler or maybe WireShark to check the network activity, see if it looks any different. Fiddler is a debugging proxy for IE, WireShark is a packet sniffer.

I can't say exactly how Firebug net monitor works, because I've never dived under the hood, but I have experienced a few things which I thought were bugs of my doing, which went away when Firebug was turned off.

It seems that Firebug in the act of measuring things, alters things in a "looking at your quantum cat" kind of a way. Firebug still rocks, but it does have some limitations.

I checked your site and using CacheViewer confirmed that it is indeed caching it and fetching it from disk, with an expiration one month from today. If you want you could also use plsicing by bining all the images into one large image and only show the area of interest, although I typically use splicing for small images, like paging icons, etc. ANyway, your site looks great and like the way you delay loading the large images.

发布评论

评论列表(0)

  1. 暂无评论