) {//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
')); 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
Link to CodelabIn this codelab, we'll retrace those steps but this time we'll use a tool called Sw-precache to add offline functionality With only six lines of code. It's never been easier to add service worker support to an existing app, and we'll show you what in this codelab.Learning:
What's the Sw-precache tool is and how it can help you being more productive
How to add a basic service worker to an existing project using Sw-precache
Install:git clone https://gith
) {returnResponse | |fetch (event.request); }) );});The Servephoto ():We want to make sure-things:
We don ' t care the photo size, 800px,200px or 40px
Because respond object can be is only access once, so we need Clone () the original one and use clone one for the CAHCE, retur n the original one to the browser.
functionServephoto (Request) {varStorageurl = Request.url.replace (/-\d+px\.jpg$/, "); returnCaches.open (Contentimgscache). Then (function(cache) {returnCache.match (S
the create the cache, but it was not a useful until we use the cache.To use the cache, we can do:Self.addeventlistener (' Install ',function(event) {varUrlstocache = [ ‘/‘, ' 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 ' ]; Event.waituntil (//Todo:open A cache named ' Wittr-static-v1 ' //ADD cache The URLs
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
Xeim this is an article published by Google Engineer Amit Singhal on Google's official blog, which describes some of the technologies behind Google's search rankings. It involves Google's understanding of webpages, semantics, and user intentions.
The core technology of Google search ranking is derived from information retrieval (IR), an academic topic that has been 50 years old. IR uses statistical principl
Google can't open Google can't open, with the Chinese mainland blocked, but mainly because of the recent googleserver in the global scope of the layout adjustment.The solution is simply to change the user's local computer Hosts file to be able to.First,How Windows system changes the Hosts fileWindows system Hosts file on local computer C drive, path is: C:\Windows\System32\drivers\etcOpen the Hosts file wit
Today, Google (Google) code search landing in Google www.google.cn/codesearch Google code search to provide you with a search on the internet can be publicly accessible source of the site, so as to help you find functional definitions and code samples. With Google code searc
There are some Google API introductions, but in actual development we may need to convert the JSON data returned by the Google RESTful API into XML data input into a third-party system, which is very common in enterprise application integration. Then there is the question of how to ensure that the converted XML data format is canonical, which requires XML Schema (XML) for validation. Now the point is, we on
the plugin. 4. Install pepper Flash Plugin:4.1. Download HUGHESJR Auxiliary installation script:cd/tmpwget https://raw.github.com/hughesjr/chromium_el_builder/master/chrome_pepperflash_copy.sh4.2. Set chrome_pepperflash_copy.sh as executable:chmod +x chrome_pepperflash_copy.sh4.3, execute the script to install (you can look at the script content to understand what happened):./chrome_pepperflash_copy.shafter installation, if you need to start from the command line (with flash support), you can e
Google has launched a feature called the local merchant center, which is officially introduced by Google. This feature allows you to easily rank your website keywords first in the search results, in addition, there are map navigation, contact information, and other content. Their graphic effects are quite attractive and more attractive than other ranking positions. However, these words can only be confined
Google Font [translated from Google official documentation], Google font
This Guide explains how to use Google Font APIs to add network fonts to your own pages. You don't need any encoding. All you have to do is add a specific CSS to the HTML page and associate the font with the CSS style.A quick example:This is an exa
Having said so much, let me first take Google Discovery RESTful services as an example to show you how to call Google Discovery RESTful services with the most common Java code.Introduction:Under "How to integrate with Google APIs and Google Apps (2)", I've listed all of the Google
In the Google RESTFul API, the Google Blogger API (Google Blog API) should be close to our lives, as nearly a lot of people are reading blogs every day and have heard of blogs. In a series of articles in front of Google's application system for integration (5) and Google's Applications for integration (6). We mentioned how to convert the JSON schema of
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.