Skip to Content
MOBILE WEB程式設計--第二版
book

MOBILE WEB程式設計--第二版

by Maximiliano Firtman
December 2013
Intermediate to advanced
752 pages
16h
Chinese
GoTop Information, Inc.
Content preview from MOBILE WEB程式設計--第二版
484
|
第十三章
之後,
countries.json
不會與其他的資源一起下載,而會在應用程式需要它時,以線上的
方式來存取。如果沒有網路連結,我們將無法取得這個檔案,除非瀏覽器有一個快取的
版本(使用典型的 Web 快取,而非應用程式快取)。
network 部分中,我們可以使用萬用字元,如
*
或資料夾;當我們處於離線操作模式
時,所有資料夾中的資源都可供存取。所以如果我們想要在使用者連上網路時,讓一個
離線應用程式存取完整的 Web,可以直接使用:
NETWORK:
*
藉由這個設定檔,只有列於
NETWORK:
段落之前的檔案會由離線封裝中載入,而其他所有
資源都會從 Web 上載入。
回退
應用程式快取有一個存取外部線上資源的機制,同時提供一個回退來避免使用者離線時
產生錯誤:
FALLBACK:
群組。在這個段落中,我們提供兩個 URL,以空格來分隔;第一
個可以使用萬用字符,第二個是個特定的 URL。例如:
FALLBACK:
images/profile.png noconnection.png
在這個範例中,當 Web App 試著取得
images/profile.png
時,如果使用者處於上線狀態,
它會由伺服器取得;如果使用者離線,它會回傳
noconnection.png
來作為回退檔案。回
退圖像私下儲存於應用程式快取封裝。
更新封裝
我們已經提到,安裝封裝之後,所有資源(包括 HTML 主文件)都是由本機存放空間載
入,而不是由 Web。因此,你一定會想到:我們該如何更新資源?當我們想要更新 CSS
主題檔、變更圖像,或在 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

成為卓越程式設計師的38項必修法則

成為卓越程式設計師的38項必修法則

Pete Goodliffe
精實企業|高績效組織如何達成創新規模化

精實企業|高績效組織如何達成創新規模化

Jez Humble, Joanne Molesky, Barry O'Reilly

Publisher Resources

ISBN: 9789862769522