PDA

View Full Version : check if users cache is full...



Coastal Web
Mar 7th, 2006, 03:44 PM
Greetings everyone,

I've noticed that gmail has a feature that alters you when your cache is full or near full that says:

"warning your cache is almost full, which may take away from the gmail experience. go here http://wwwsomeurl.com to learn how to fix this"

I was just curious as to how they are able to check if the cache is full or not. I'm guessing this is done with javascript. Any help on this would be greatly appreciated! :D

Philip M
Mar 7th, 2006, 05:39 PM
No, it is not done with javaScript, which is a client-side language and cannot read from or write to a file.

Beagle
Mar 7th, 2006, 08:14 PM
Phillip, can you verify this?

I think it CAN be done with JavaScript.

JavaScript CAN get access to many pieces of browser information if the script is signed and the user accepts the license. In this case, a signed script may be getting access to the ~browser's~ cache.

If it can, it would probably get there through something browser.cache.maxsize, or something similar. I've never tried it, ask google.

liorean
Mar 7th, 2006, 08:25 PM
Well, there is no standard way to check it JavaScript, that's for sure. I've not heard of any way to do it either. I would guess Google uses some method related to whether a file is requested more than once or something like that. But I haven't looked closer at their code, so by all meassures I might be wrong.

Beagle
Mar 7th, 2006, 09:29 PM
I'll put a bounty on this information.

I'll donate US$10 to the organization of your choice (open-source project, free online game, non-profit org) if you can figure out and show us a repeatable example of how google accomplishes this cache checking.

Any submission claiming the bounty is subject to peer review on this forum and the donation will only be made if there is a majority amongst the CF regulars posting on the thread that agree your submission was the first acceptable one.

Coastal Web
Mar 7th, 2006, 10:50 PM
Yes, l disagree with Philip M's comment as well ...
I think that it is possible to do with Javascript

also - l have not accepted any licensed pop-ups or anything from google (that l can remember). Here is a screen shot of what l'm talking about, if anyone hasn't seen it before:
http://img364.imageshack.us/img364/4677/googleimage1bb.jpg

After poking around the source a bit, this is the only javascript l can find:

<SCRIPT>
<!--

var fs_time=(new Date()).getTime();




function wfs() {


try {
if (parent!=window && parent.wfs) {
return false;
}
}catch(e){}



if (top.location.href.indexOf('nocheckbrowser')!=-1) {
return true;
}




if (!is_browser_supported) {
top.location="?ui=html&zy=j";
return false;
}


var testcookie='jscookietest=valid';
document.cookie=testcookie;
if (document.cookie.indexOf(testcookie)==-1) {
top.location="html\x2Fnocookies.html";
return false;
}

document.cookie=testcookie+';expires=Thu, 01 Jan 1970 00:00:00 GMT';


var agt=navigator.userAgent.toLowerCase();


if (agt.indexOf('msie')!=-1 && document.all &&
agt.indexOf('opera')==-1 && agt.indexOf('mac')==-1) {


eval('var c=(agt.indexOf("msie 5")!=-1)?"Microsoft.XMLHTTP":"Msxml2.XMLHTTP";try{new ActiveXObject(c);}catch(e){top.location="html\x2Fnoactivex.html";}');
}


return true;

}

function lj() {

js.location.replace("?view=page&name=js&ver=f2a95ab6ec6e3acd");

}


if (wfs()) {


document.write('<frameset onload=lj() rows="100%,*" border=0><frame name=main src="html/loading.html" frameborder=0 noresize scrolling=no><frame name=js src="html/loading.html" frameborder=0 noresize></frameset>');
}
-->
</SCRIPT>

This sure is something l would like to know how to do.
Thanks for the help folks.

S. Gram

NickPresta
Mar 7th, 2006, 11:30 PM
http://ajaxpatterns.org/Browser-Side_Cache
http://www.mnot.net/javascript/xmlhttprequest/cache.html
http://vbnet.mvps.org/index.html?code/internet/dispcallfunc_historydelete.htm

I searched for a while and I couldn't find anything. I'll see what I can do. If you get that cache message from gmail, save all the files (html and JS) and I'll go over them to see what's going on.

Coastal Web
Mar 8th, 2006, 02:37 AM
I searched for a while and I couldn't find anything. I'll see what I can do. If you get that cache message from gmail, save all the files (html and JS) and I'll go over them to see what's going on.

Hey Nick,
Thanks for the reply -- I will do that the next time the message pops up. I did the same thing myself (searched through the sources for some kind of reference to the cache) but didn't find anything...

Will post back next time it happens.

SG

Philip M
Mar 8th, 2006, 07:23 AM
I'll put a bounty on this information.

I'll donate US$10 to the organization of your choice (open-source project, free online game, non-profit org) if you can figure out and show us a repeatable example of how google accomplishes this cache checking.

Any submission claiming the bounty is subject to peer review on this forum and the donation will only be made if there is a majority amongst the CF regulars posting on the thread that agree your submission was the first acceptable one.

I'll double that and donate US$20. Will Samantha do the same if no-one can show how this may be done using JavaScript?

felgall
Mar 8th, 2006, 07:40 PM
The way cache works it can never be full and anything that claims to function differently is lying to you. Cache automatically discards files once the area approaches full so as tomake room for more files. This happens automatically with the software handling the cache deciding what files you are least likely to need in order to discard them.

Cache should always be almost full for optimal performance (which is what the cache is there for in the first place).

Coastal Web
Mar 9th, 2006, 10:26 PM
You know what, yes l'll throw in $5 USD via paypal to whomever it is that can produce a working concept with javascript, or even a server side scripting language such as PHP. This was just more of a question than anything, it's not something l needed for a program/site l was working on, just me being curious is all.

So that brings it up to $35

SG

Beagle
Mar 9th, 2006, 10:31 PM
My $10 would prefer to be donated to an non-profit, OSS project, or donation driven service, but it can go to the answerer if it must. Just to clarify.

jeffburton
Mar 31st, 2006, 01:08 PM
I have to disagree with felgall. In an ideal world, browsers might work the way he or she described, but browsers are full of bugs. In particular, IE can behave erratically when the cache is full. That is why gmail is doing what it is doing. I also would like to know how gmail does it. I foolishly cleared my browser cache when I received that message. Now I will have to wait until my cache fills up (anyone have a quick way to do that?). Then I will put a scope on the HTTP transactions and figure it out, because I am going to post a similar message in my application when people using IE have a full cache.

Kravvitz
Mar 31st, 2006, 06:08 PM
You could change the maximum size of your Temporary Internet Files folder. Tools => Internet Options => General => Settings.

P.S. Since felgall's (real) first name is Stephen, I'm pretty sure he's a he. :p

jeffburton
Mar 31st, 2006, 06:15 PM
Thanks, but tried that - gmail is not picking up a 5 megabyte full cache.