Re: checking cache
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Sun, 12 Aug 2007 22:11:31 -0400
Active Discovery Development said the following on 8/12/2007 9:44 PM:
"Evertjan." <exjxw.hannivoort@xxxxxxxxxxxx> wrote in message news:Xns99886AEFC1922eejj99@xxxxxxxxxxxxxxxxxxActive Discovery Development wrote on 10 aug 2007 inthanks for replying.. so cache checking is not possible, then how to measure the loading time? do you have any idea?
microsoft.public.scripting.jscript:
hello everyone!For an image?
i just want to ask if cache checking is possible in javascript?
No that would be a breach of security.
You could try to measure the loading time though.
If it is unrealisticly short, then ....
Set a variable to the current time.
Retrieve the file.
Set a second variable to the current time.
Subtract the two times.
var start = new Date().getTime()
var someImage = new Image()
someImage.src = "theFile.ext"
someImage.onload = checkIt
function checkIt(){
var end = new Date().getTime()
var totalTime = end - start
alert('It took about ' + totalTime + 'milliseconds to do that')
}
Untested but the steps are there.
If totalTime is 1 second and the file is .5 mb's then you can reasonably assume it was in the cache. If it is longer, then it wasn't but now it is.
Anything you do to try to detect whether a file is in the cache or not is going to put it in the cache if it isn't already there so the timing becomes an exercise in academia and not worth a whole lot.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.
- Follow-Ups:
- Re: checking cache
- From: Evertjan.
- Re: checking cache
- From: Active Discovery Development
- Re: checking cache
- References:
- checking cache
- From: Active Discovery Development
- Re: checking cache
- From: Evertjan.
- Re: checking cache
- From: Active Discovery Development
- checking cache
- Prev by Date: Re: checking cache
- Next by Date: Re: checking cache
- Previous by thread: Re: checking cache
- Next by thread: Re: checking cache
- Index(es):
Relevant Pages
|