简体   繁体   中英

as3 URLLoader Cache suggestions for mobile app

I have been looking around for a class to manage the caching of the data from a URLLoader call but been unsuccessful. Does URLLoader cache by default?

I am building an app that fetches a bunch of information on the user (profile details, friend lists, profile image etc) and I would prefer not to call URLLoader each time. I am caching their profile image on first load and hope I can do the same with the rest of the data without having to create a clone of the DB locally.

Cheers

Yes, the URLLoader caches requests, and there are various solutions to break that cache request (generally by adding a random element to the end of the web request). You can see the documentation here for the URLRequest object that's returned, and it's various cache options.

However, I recommend persisting the data locally upon receiving the request and using the platform's database / data storage pattern that you're on. Then, check for internet prior to making the request: if you can make a connection, make the request to retrieve and update the local data. If there's no internet / connection, just load the data you have saved locally. Using the "cached" version of the request isn't a trustworthy pattern.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM