2014-06-21 100 views
1

我剛剛讀完了關於緩存/脫機的一些稀疏教程,以及關於在用戶未連接到互聯網時使應用程序響應的問題。這是非常有趣的,因爲我一直在想如何做一些應用程序,因爲我認爲這是一些數據庫操作。JQuery Mobile,PhoneGap應用程序中數據的動態緩存

我對緩存機制比較陌生,我真的想在我的下一個項目中實現它,因爲我仍然在學習。

我看了一下緩存靜態文件如圖片,.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?

這個問題可能聽起來真的很小白,但我真的想學習,我已經讀了很多有關緩存,但這些問題並沒有解決。我只是希望有人幫助。謝謝...

回答

1

答案是根據我的知識給出的。

1)您可以使用localStorage存儲/緩存事物它非常基礎,因此不需要很多時間或編碼或機制來實現。配置文件數據,作爲編碼字符串的圖像可以保存在localSorage中。首先,您會將配置文件數據保存在localStorage中。然後下次在應用程序啓動後,您可以從localStorage加載數據,同時您也可以向服務器發出異步ajax調用以檢查數據是否已修改。如果是這樣,那麼你可以再次使用這些數據並更新localStorage。 2)如果你使用localStorage,那麼直到達到5MB的localStorage大小限制才能進行頁面轉換。

相關問題