是否可以製作離線工作的網絡應用程序? (Is it possible to make a web-app which works offline?)


問題描述

是否可以製作離線工作的網絡應用程序? (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

Application Cache

  • 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.

(by CoreyCorey)

參考文件

  1. Is it possible to make a web‑app which works offline? (CC BY‑SA 2.5/3.0/4.0)

#javascript #css #html






相關問題

為什麼我不能在 IE8 (javascript) 上擴展 localStorage? (Why can't I extend localStorage on IE8 (javascript)?)

在 Javascript 中打開外部 sqlite3 數據庫 (Open external sqlite3 database in Javascript)

Javascript:數組中的所有對像都具有相同的屬性 (Javascript: All Objects in Array Have Same Properties)

為什麼我們要在 javascripts 原型中添加函數? (Why do we add functions to javascripts prototype?)

顯示 URL javascript 的最後一部分? (Display the last part of URL javascript?)

Javascript XMLHttpRequest:忽略無效的 SSL 證書 (Javascript XMLHttpRequest: Ignore invalid SSL Certificate)

有沒有辦法測試 console.log 整體 (Is there a way to test for console.log entires)

如何從 javascript 對像中獲取名稱和值到新列表中? (How to get name and values from a javascript object into a new list?)

數據未發布..幫助!html,js,firebase (Data not posting.. Help! html,js,firebase)

使用 Node.js 腳本查看表單數據 (Seeing form data with Node.js script)

使用百分比查找範圍內的值 (find the value within a range using percent)

如何通過 react.js 中的組件傳遞變量或數據? (How to pass varible or data through components in react.js?)







留言討論