【问题标题】:Dynamic Caching of Data in JQuery Mobile, PhoneGap ApplicationJQuery Mobile、PhoneGap 应用程序中的数据动态缓存
【发布时间】:2014-08-11 23:11:54
【问题描述】:

我刚刚阅读了一些关于缓存/离线的稀疏教程,以及关于在用户未连接到互联网时使应用程序响应的内容。这很有趣,因为我一直想知道某些应用程序是如何做到这一点的,因为我认为这是一些数据库操作。

我对缓存机制比较陌生,我真的很想在我的下一个项目中实现它,因为我还在学习。

我读过的一些教程谈到了缓存静态文件,如图片、.css 文件、.js 文件等

我的问题是这样的;

**Question 1** How do I cache Dynamic Files e.g I have an Apps when a User want to view their profile, I normally implement it by sending an Ajax request to the server to populate the profile page with pictures and other profile details (texts). How Do I cache these texts and pictures since they are dynamic?

**Question 2** I am using different page (index.html, profile.html) JQuery Mobile mechanism, will this affect caching in any way because I have to refresh the page every time I am navigating to a new page so as to show my styling correctly?

这个问题听起来可能很菜鸟,但我真的很想学习,我已经阅读了很多关于缓存的内容,但这些问题没有得到解决。我只是希望有人帮忙。谢谢...

【问题讨论】:

    标签: android jquery html caching cordova


    【解决方案1】:

    根据我目前的知识给出答案。

    1) 您可以使用localStorage 存储/缓存内容,它非常基础,因此不会花费大量时间或编码或机制来实现。配置文件数据,图像作为编码字符串可以保存在localSorage中。首先,您将在 localStorage 中保存配置文件数据。然后下次应用程序启动后,您可以从 localStorage 加载数据,同时您可以对服务器进行异步 ajax 调用以检查数据是否被修改。如果是这样,那么您可以再次获取该数据并更新 localStorage。

    2) 如果您使用 localStorage,那么在您达到 5 mb 的 localStorage 大小限制之前,页面转换不会成为问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 2019-04-08
      • 1970-01-01
      相关资源
      最近更新 更多