Re: checking cache
- From: "Active Discovery Development" <development@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Aug 2007 10:24:19 +0800
"Randy Webb" <HikksNotAtHome@xxxxxxx> wrote in message
news:IpmdncWcEKROICLbRVn_vgA@xxxxxxxxxxxxxxx
Active Discovery Development said the following on 8/12/2007 9:44 PM:
"Evertjan." <exjxw.hannivoort@xxxxxxxxxxxx> wrote in message
news:Xns99886AEFC1922eejj99@xxxxxxxxxxxxxxxxxx
Active Discovery Development wrote on 10 aug 2007 inthanks for replying.. so cache checking is not possible, then how to
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 ....
measure the loading time? do you have any idea?
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/
thanks for the code Randy! i appreciate it a lot. this will help me big!
Good day!
.
- References:
- checking cache
- From: Active Discovery Development
- Re: checking cache
- From: Evertjan.
- Re: checking cache
- From: Active Discovery Development
- Re: checking cache
- From: Randy Webb
- checking cache
- Prev by Date: Re: checking cache
- Next by Date: Calendar date function
- Previous by thread: Re: checking cache
- Next by thread: Re: checking cache
- Index(es):
Relevant Pages
|