問題描述
是否可以製作離線工作的網絡應用程序? (Is it possible to make a web‑app which works offline?)
我知道如果平板電腦/手機離線一段時間,我可以利用客戶端存儲、cookie、WebSQL 來製作獨立於互聯網的應用程序。但是在一天結束時,如果用戶刷新瀏覽器,該站點將嘗試加載 HTML/CSS/JS 並且它將無法加載。去年我沒有跟上 HTML5 的增強,所以我想知道是否存在這樣的東西。例如,明確告訴瀏覽器緩存靜態資產並在重新加載時再次使用它們,除非存在較新的版本。
注意:如果存在這種情況,我只對如何允許頁面通過離線站點重新加載感興趣。
參考解法
方法 1:
I believe that @NickZuber has answer my question with his link. The thing I was looking for is
- Works on most (90%+) modern browsers Best suited for storing application code
- The only option to reliably load a website from nothing offline
- Can storage a significant amount of data (50mb+)
- Very difficult use without causing unintended consequences for most websites
Here is a working example of it in action. You can essentially turn off your internet, hit refresh on the browser, close the browser and re‑open it. Whatever you want and the app loads up just fine complete with Images, CSS Styles, and Javascript.