Assets.images and http requests

1 view
Skip to first unread message

stratboy

unread,
Nov 21, 2009, 9:39:04 AM11/21/09
to MooTools Users
Hi! I've got a little question: let's suppose I'm using Assets.images
twice (in the same page) and to load, say, the same 5 images. Does the
second call generate 5 more http requests? Is that bad or I shoudn't
worry about it?

CroNiX

unread,
Nov 22, 2009, 2:48:48 PM11/22/09
to MooTools Users
I guess my question is why you are retrieving the same data twice?
Why not just reuse the result from the first request?

stratboy

unread,
Nov 23, 2009, 10:38:43 AM11/23/09
to MooTools Users
Because I really can't do it :)

So, is there anyone that can answer my original question?

I've taken a look to the class Assets, and it seems it doesn't check
if images are already cached. I've also tried to see some tracing from
firebug and safari activity and it seems the don't reload images. I
don't know if this is always true, and if it's true for IE too.

Any guru? :)

eskimoblood

unread,
Nov 23, 2009, 10:45:51 AM11/23/09
to MooTools Users
No it will not request the images again, cause they are all in the
browsers cache at this point.

pradador

unread,
Nov 23, 2009, 1:37:53 PM11/23/09
to MooTools Users
IMO, http requests are bad for your app as they tend to be a
bottleneck area depending on the concurrent requests a browser makes
(older browsers do only two connections at a time for example). But
with modern browsers you can count on them being smart and loading the
same image from the local cache instead of hitting the server. So in
general terms you could probably not worry about it and never see
unneeded requests.

That being said, you end up counting on "magic" on the browser's part
and would be better off ensuring your app only calls Asset.images once
to preload the images and then just cloning the resulting image
elements as needed to ensure no unneeded requests are ever made.

stratboy

unread,
Nov 23, 2009, 1:45:12 PM11/23/09
to MooTools Users
Thank you all for the answers guys :)
Reply all
Reply to author
Forward
0 new messages