Re: checking cache

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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 in
microsoft.public.scripting.jscript:

hello everyone!

i just want to ask if cache checking is possible in javascript?
For an image?

No that would be a breach of security.

You could try to measure the loading time though.
If it is unrealisticly short, then ....

thanks for replying.. so cache checking is not possible, then how to 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/
.



Relevant Pages

  • Re: Dramatic speed effect of code-data proximity
    ... depending on whether or not the address 'var' is in the same 1 Kbyte ... I'm guessing that the data write invalidates the code cache, ... it to be reloaded from main memory each time around the loop. ...
    (comp.lang.asm.x86)
  • Re: in memory data
    ... var can be used, IMO there is no big difference. ... then answer can be session cache. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: checking cache
    ... i just want to ask if cache checking is possible in javascript? ... var start = new Date.getTime ... var totalTime = end - start ... assume it was in the cache. ...
    (microsoft.public.scripting.jscript)
  • Re: where should I save temporary values
    ... put it in the application cache: ... if it is user specfic data, put it into session state or viewstate: ... database, in the separate table. ... from var)" 'both names ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Reload a page when back button pressed
    ... also if you look at google's web tool kit's browser history management object, to see what others are doing. ... instead of being server based spewing javascript, its browser based with ajax calls to the server. ... The browser retrieves the page from the cache. ...
    (microsoft.public.dotnet.framework.aspnet)