Jump to content
Search Community

testing if file is already in cache

scottwitte test
Moderator Tag

Recommended Posts

Jack,

 

Is there a way for LoaderMax to test if a file is already in the browser cache and let you know?

 

Here's what I'm thinking: You build a preloading queue. A file request comes. Normally, if it is a significant file, you want to pause/cancel the queue giving all available bandwidth to download the requested file ASAP. In doing so you loose all the data currently downloading but not yet finished and you have to start again once the requested file is finished. BUT, if the file is already in the browser cache stopping the queue is entirely unnecessary. Flash would quickly pull the file from cache. LoaderMax could keep going with no pause, no loss of data or time.... if you only knew.

Link to comment
Share on other sites

As far as I know, it's impossible to actually query the cache and find out what files a user has on their hard drive like that (for obvious security reasons) but you CAN check the status of a loader anytime which really should give you everything you need. Just do something like:

 

if (myLoader.status != LoaderStatus.COMPLETED) {
   myLoader.prioritize();
}

 

If the status is LoaderStatus.COMPLETED, you know it loaded and is in the browser's cache.

Link to comment
Share on other sites

you CAN check the status of a loader anytime which really should give you everything you need.

 

Yes. Already doing that. But if LoaderMax hasn't gotten to that particular file in its queue it still won't know if it is cached or not. Status will be "ready" either way. I was hoping that something like auditSize() could report if the file was cached as well as its byte size by some cleaver method.

Link to comment
Share on other sites

I'm confused - if it hasn't loaded yet, how would it be in the cache? Are you saying maybe the user loaded it during a completely different session or something? If so, yeah, there's no way to check that without just loading it and seeing how quickly it is loading (kbps) which would obviously take a little time.

Link to comment
Share on other sites

I'm confused - if it hasn't loaded yet, how would it be in the cache?

 

In my case I build 360VR tours that may consist of a couple dozen nodes (views), each a couple MB in size. The user may have viewed one or a couple separately, say as a sample in a different part of the site. Now they view the full tour and that sample view sits near the end of the queue. But say the user decides to jump straight to it. It would already be in cache. LoaderMax wouldn't know.

 

I hope that is clear, but it may not matter. There is no flag that will tell you the file is in cache if it hasn't already been processed by LoaderMax. If testing the download speed of a file sample is the only way it may get complex and not be worth the overhead of running such a test.

Link to comment
Share on other sites

Yes. I thought of that. I don't have experience with shared objects but from what I understand there would be problems. For instance, when a file is flushed from the cache there is no way I know to update the shared object's record.

 

A better approach might be to build a database at the beginning of each session. I could build a LoaderMax queue of all possible files I may want to queue up. I could load the queue but stop each loader after xx ms. Those files already in cache would complete and could be marked as such in an array or dictionary. All others would be assumed to not be cached. I would have to do a lot of experimentation to figure out exactly how to make that work on the wide variety of systems out there. It's an idea, anyway.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...