Intead of Cache The root floder, we want to cache skeleton instead. self.addeventlistener (' Install ', function function return
Cache.addall ([
'/ ' js/main.js ' ' css/main.css ' , ' imgs/icon.png ' , ' https://fonts.gstatic.com/s /roboto/v15/2ux7wltfw3w8tcltuvlfyq.woff ' , ' https://fonts.gstatic.com/s /roboto/v15/d-6iyplofoccackzxwxsod8e0i7kzn-epnyo3hzu7kw.woff ' Respond to requests for the root page with thepage skeleton from the cache:Self.addeventlisten
' }); Store.createindex (' by-date ', ' time '); });In _opensocket, we had a function to fetch the old data from the IDB.// Open a connection to the server for live updates function () {... Ws.addeventlistener (function(event) { requestanimationframe() { Indexcontroller. _onsocketmessage (event.data); }); ...};//called when the Web socket sends message dataIndexcontroller.prototype._onsocketmessage =function(data) {varMessages =json.parse (data); This. _dbpromise.then (func
all the messages, //gather all the photo URLs. // //Open the ' Wittr-content-imgs ' cache, and delete any entry //That you no longer need. varPhotostokeep = []; vartx = Db.transaction (' Wittrs '); returnTx.objectstore (' Wittrs '). GetAll (). Then (function(Messages) {Messages.foreach (function(message) {if(Message.photo) {Photostokeep.push (Message.photo); } }); returnCaches.open (' Wittr-content-imgs '); }). Then (function(cach
) {//wait all cache deleted returnPromise.all (//filter out staticcachename (only keep Staticcachename)Cachenames.filter (function (name) {returnName.startswith ('wittr') Name! =Staticcachename; }). map (function (name) {//Delete cache, return promise returncaches.delete (name); }) ) }) )})So in the code, the static one is ' wittr-demo-v13 '.We Use the APIs:// return a promise with all the cache name // return a promise and delete the selecte
= Db.transaction (' People '); varPeoplestore = Tx.objectstore (' People ')); returnPeoplestore. GetAll
(); }). Then (function(People) {console.table (people);});
Group by:To does gourp by we need to create INDEX: Import IDB from ' IDB '; varDbpromise = Idb.open (' test-db ', 3,function(upgradedb) {Switch(upgradedb.oldversion) { Case0:
//Keyval Store is already created at version 1
varKeyvalstore = Upgradedb.createobjectstore (' Keyval ')); Keyvalstore.put ("Wo
Most of the analysis results show that some tasks of the project have unreasonable logic in allocation and work hours, leading to exceptions in the webpart. Usually, the PWA System maintenance staff will be crazy at this time, because no one changes the settings, the server services are normal, and this logical error occurs inadvertently under the project manager. I felt that the last second was still good, and suddenly I got down. (For administrators
')); Peoplestore.put ({name:"John",//name is the keyAge:23, Favoriteanimal:' Cat ' }); Peoplestore.put ({name:"Joe",//name is the keyAge:21, Favoriteanimal:' Cat ' }); Peoplestore.put ({name:"Jie",//name is the keyAge:22, Favoriteanimal:' Dog ' }); Peoplestore.put ({name:"Jay",//name is the keyAge:24, Favoriteanimal:' Dog ' }); returnTx.complete;}). Then (function() {Console.log ("People is added");}); Dbpromise.then (function(db) {vartx = Db.transaction (' People ', ' ReadWrite ');
(' Updatefound ',function(){ //reg.installing is changed })})Api:linkFor the service worker itself:var sw =// ... logs "Installing"/ /// "Installed" // "activating"/ /" avvtivated"// "redundant" Sw.addeventlistener (function() { // Sw.state has changed })Aslo about:Naviagetor.serviceWorker.controller"Navigator.serviceWorker.controller" refer to the service worker, that controls the page.So if there was no controller, then it means the data was loading from network:if (! Naviga
the root scope, so it's available to all the Child components.2. Our service worker file:// Sw.js Self.addeventlistener ('fetch', function (event) { Console.log (event. request);});Once you fetch the page seond time (first time service work do cache stuff), second time you'll see in the console, the Re is lots of requests log out.
Of course, service worker has other event listeners:Self.addeventlistener ('Install', Function (Event) { // ..}); Self.addeventlistener ('Activate', Function
Label:Use the library indexeddb-promised. Create a database and Stroe: Import IDB from ' IDB ';
// Open (db_name, version, CB)
var function (upgradedb) {
var// CREATE TABLE
//put (value, key )
keyvalstore.put (' World ', ' Hello ')
; Notice put () function take value frist then key. Read the key in Stroe: // read "Hello" in "Keyval"
Dbpromise.then (function (db) {
var// Open a transaction
var// read the store
return// Get value by key
}). Then (function (val)
When we save items to indexdb, we need to think about clean the items or keep those in a short list.Indexcontroller.prototype._onsocketmessage =function (data) {varMessages =json.parse (data); This. _dbpromise.then (function (db) {if(!DB)return; vartx = Db.transaction ('Wittrs','ReadWrite'); varstore = Tx.objectstore ('Wittrs'); Messages.foreach (function (message) {store.put (message); }); //Todo:keep The newest, entries in ' Wittrs ',//But delete the rest. // //hint:you can use. open
service worker and Cachestorage cache and offline development demoTo enter the page, we tick the offline in the network, such as:When the results are refreshed, the page will still load normally, as shown in GIF screenshot:Our off-line functionality was achieved in this, surprisingly simple and practical.V. The relationship with PWA technologyPWA is all called "
Tags: blog http io using ar strong for file dataDatabase Administrators can have any tablespace online (online) (accessible) or offline (offline) (inaccessible) in the open (open) State of the database in addition to the SYSTEM tablespace (tablespace). The SYSTEM table space is always online when the database is open (open), because Oracle needs to use the data dictionary in the dictionary.Table spaces (tab
What is an offline network application? At first glance, it is like a contradiction in the following ways. The Web page is downloaded and rendered. Downloading means a network connection. How can you download it offline? Of course, you can't. But you can download it when you are online. This is how the HTML5 offline application works.In the simplest terms, an
April 8 " off, or not," ArcGIS Mobile's "offline integration" is there! "The Mobile Open class has ended, and the blog has given a specific answer to the concerns of the fans in the Open class. Questions and answers are mainly around the latest runtime SDKs, the use of the latest offline features, and the licensing of the new version number. For a lot of other details, please visit the public class Video: h
HTML5 offline storage and HTML5 offline storage
When a user is not connected to the Internet, the user can normally access the site or application and update the cached files on the user's machine when the user is connected to the Internet.Principle: HTML5 offline storage is based on a new one. the cache mechanism of appcache files (not the storage technology). B
Android offline download knowledge, android offline
The offline download function is as follows:1. Download Management (START and cancel download ).2. Network judgment (wi-fi, 3G ).3. Independent process.4. timed and mobile phone reminders.5. self-starting.
Select the core method for offline downloadWhen the backend ru
Use. NET Core in offline environments and. netcore in offline environmentsUse. NET Core0x00 in offline environment to write at the beginning
I have been paying close attention to. NET Core for a long time. Microsoft's previous impressions have become lightweight, open-source, and cross-platform. I plan to try it at work recently. However, the work is carried out
Comments: Today, our content is about how to create an offline web application. Its advantage is that it allows the browser to download our specified web resources so that users can use our site normally offline.
Today, our content is about how to create an offline web application. Its advantage is that it allows the browser to download our specified web resource
Overview
With the Dojo offline feature, you can save page content and its associated pictures, CSS, and JavaScript resources while the page is loaded, so that even when we are offline we can continue to manipulate the page, and the contents of the operation can be faithfully stored locally, and automatically synchronizes to the service side when the connection to the server is restored. Using the Dojo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.