Jump to content
Search Community

load(true) not flushing content??

scottwitte test
Moderator Tag

Recommended Posts

Jack,

 

What am I doing wrong? My objective is to force the download of some files from the server even if they are currently in the browser cache. My understanding is that load(true) would do that by flushing those files from the cache before starting the load, but it doesn't seem to be working for me. For example:

 

var speedLoader:LoaderMax;
speedLoader = new LoaderMax({onComplete:endSpeedTest, maxConnections:6, auditSize:false});;
var _url:String;
for (var i:uint=0; i<6; i++) {
_url = "images/speedtest_"+i+".jpg"
speedLoader.append( new ImageLoader(_url, {estimatedBytes:179372}));
}
speedLoader.load(true);

If I clear the browser cache and run this it takes some seconds to complete. If I then reload the page (not clearing browser cache) and run this again it takes 0.1 seconds to complete. Obviously the files are not being flushed from the cache by load(true). So, what should I do to accomplish my objective?

 

If I weren't using loaderMax I might try something involving " req.method = URLRequestMethod.POST; " But that doesn't seem applicable here.

 

Thanks,

Scott

Link to comment
Share on other sites

load(true) has nothing to do with flushing the browser's cache (Flash can't do that) - it simply unloads the content from the Flash Player. What you're talking about is setting noCache to true on the loader. You do that via the vars object, like:

var loader:ImageLoader = new ImageLoader("1.jpg", {noCache:true});

 

That will make sure that each load() call will append a unique number to the end of the URL to prevent it from loading a cached version of the file.

 

If you need to set that value AFTER you created your loader instance, you could do so like myLoader.vars.noCache = true;

Link to comment
Share on other sites

What you're talking about is setting noCache to true on the loader.

 

That is what I had been doing for the past several months until it occurred to me that it wasted bandwidth. My intent is to determine a visitor's download speed to help them decide if they want to view the site in the smaller, faster loading version or in full screen version with its larger file sizes and slower download. You can see what I mean here: http://www.tourdeforce360.com/madison

 

So I figure, rather than download a file that simply gets dumped, use the first low resolution file. That way if they choose to view in SD the file is already there. No added bandwidth. (And this site has been burning through lots of bandwidth.) Of course it doesn't work correctly if the file is already in cache.

 

But apparently Flash provides a way to force download from the server, not cache. As I understand it that would be "req.method = URLRequestMethod.POST" Might it make sense to add this capability to loaderMax?

 

BTW, it may already be obvious to most, but for folk like me a little extra clarification in the docs about what flushing does (or doesn't do) could be helpful.

 

Thanks, as always.

Link to comment
Share on other sites

But apparently Flash provides a way to force download from the server, not cache. As I understand it that would be "req.method = URLRequestMethod.POST" Might it make sense to add this capability to loaderMax?

You can already do that by creating your own URLRequest (with its method property set to "post") and pass that into the loader as the URL (remember, the first parameter can be either a String URL or a URLRequest object).

 

I don't think it would be wise for me to add some other special feature that forces the method to "post" to avoid caching because it could screw up other things, like if the user's server can't accept "post" data or if they created their own URLRequest object that has its method set to "get" because their server-side script is looking for the variables in that particular way - if I set it to "post", it would break their script because suddenly the variables that they were expecting in the "get" url won't be there. I think it's much cleaner to append the gsCacheBusterID to the URL itself. I appreciate the recommendation, though. And again, you can get the effect you're after by using noCache:true (unless I'm misunderstanding what you were saying).

Link to comment
Share on other sites

You can already do that by creating your own URLRequest (with its method property set to "post") and pass that into the loader as the URL (remember, the first parameter can be either a String URL or a URLRequest object).

Brilliant!! That totally escaped me but it seems it should do exactly what I want. Actually, it is pretty darn cool how flexible your classes can be. I will give this a shot.

 

Thanks.

 

Scott

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...