简体   繁体   English

针对移动应用的as3 URLLoader缓存建议

[英]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. 我一直在寻找一个类来管理URLLoader调用中的数据缓存,但是没有成功。 Does URLLoader cache by default? URLLoader是否默认缓存?

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. 我正在构建一个应用程序,该应用程序可获取有关用户的大量信息(个人资料详细信息,朋友列表,个人资料图像等),并且我不希望每次都不调用URLLoader。 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). 是的,URLLoader缓存请求,并且有多种解决方案来中断该缓存请求(通常通过在Web请求的末尾添加一个随机元素)。 You can see the documentation here for the URLRequest object that's returned, and it's various cache options. 您可以在此处查看有关返回的URLRequest对象文档 ,以及各种缓存选项。

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. 然后,在发出请求之前检查Internet:如果可以建立连接,则发出请求以检索和更新本地数据。 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. 使用请求的“缓存”版本不是可信赖的模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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