ããã«ã¡ã¯ãHabrïŒ ç§ã®ååã¯Slava Volkovã§ããç§ã¯Badooã®ããã³ããšã³ãéçºè
ã§ãã ä»æ¥ã¯ãããã³ããšã³ãããçµ±èšãåéããããšã«ã€ããŠå°ãã話ãããããšæããŸãã
ã¢ããªãã£ã¯ã¹ã䜿çšãããšãä»»æã®Webãµã€ãã®ããã©ãŒãã³ã¹ãè©äŸ¡ãããã®äœæ¥ãæ¹åã§ããããã売ãäžããå¢ããããŠãŒã¶ãŒã®ãµã€ããšã®å¯Ÿè©±ãæ¹åã§ããããšãããã£ãŠããŸãã ç°¡åã«èšãã°ãåæã¯ãWebãµã€ãã§è¡ãããããã»ã¹ãå¶åŸ¡ããæ¹æ³ã§ãã ã»ãšãã©ã®å Žåãéåžžã®ãµã€ãã§ã¯ãGoogleã¢ããªãã£ã¯ã¹ãŸãã¯Yandex.Metricaãã€ã³ã¹ããŒã«ããã ãã§ååã§ãããã®æ©èœã¯ååã§ãã
ããããæšæºã®ç£èŠããŒã«ã§ã¯äžååãªå Žåã¯ã©ãã§ããããïŒ ãŸãã¯ãåéãããçµ±èšãç¬èªã®åæã·ã¹ãã ã«çµ±åããŠãç°ãªãã³ã³ããŒãã³ãéã§äœãèµ·ãã£ãŠããããå®å
šã«ææ¡ããå¿
èŠãããå Žåã¯ã©ãã§ããããïŒ ãã®å Žåãã»ãšãã©ã®å Žåãã·ã¹ãã ãéçºããå¿
èŠããããŸãã ãããããŠã§ããµã€ãããçµ±èšãéä¿¡ããæè¯ã®æ¹æ³ãã©ã®ãããªåé¡ãçºçããå¯èœæ§ããããã©ã®ããã«ããããåé¿ãããã«ã€ããŠã¯ããã®èšäºã§èª¬æããŸãã ã«èå³ããããŸããïŒ ç«ãžããããã
Badooãªã©ã®ãµãŒãã¹ã®å Žåãçµ±èšæ
å ±ã¯ããªãœãŒã¹ã®çŸåšã®ç¶æ³ããŠãŒã¶ãŒã®ã¯ãªãã¯ãèŠããããã¯ãå®è¡ããã¢ã¯ã·ã§ã³ããµã€ãã§ã®äœæ¥äžã®ãšã©ãŒãªã©ãè©äŸ¡ããããã®éåžžã«éèŠãªæ¹æ³ã§ãã ãã®æ
å ±ã«åºã¥ããŠããµã€ããç£èŠããæ°ããæ©èœã®å€èŠ³ãããŒãžäžã®ãããã¯ã®äœçœ®ã®å€æŽããã®ä»ã®å€æŽãäŸåãããã©ãããå€æããŸãã ãããã£ãŠãéåžžã«å€æ§ãªçµ±èšã䜿çšããŸãã ãã®ãããªã¡ãã»ãŒãžã®æµãã«ééãããšãã©ã®ãããªå°é£ã«çŽé¢ããã§ããããïŒ
çºçããå¯èœæ§ã®ããæåã®åé¡ã¯ã1ã€ã®ãã¡ã€ã³ãžã®åææ¥ç¶æ°ã«é¢ãããã©ãŠã¶ãŒã®å¶éã§ãã ããšãã°ãããŒãžãããŒããããšãã4ã€ã®Ajaxãªã¯ãšã¹ããå®è¡ããŠããŒã¿ãååŸãïŒãã©ã³ããSVGã°ã©ãã£ãã¯ã¹ãããŠã³ããŒãïŒãã¹ã¿ã€ã«ãåçã«ããŒãããŸãã ãã®çµæããã©ãŠã¶ãŒãåæã«å®è¡ãã6ã€ã®ãªã¯ãšã¹ããåãåããŸãïŒ äŸçªå·1 ïŒïŒãã¹ãŠã®äŸã§ãé
延ã2ç§ã«èšå®ãããããã¯ãŒã¯é
延ãåé¿ããããã«ãã·ã³äžã§ç£èŠããæ¹ãè¯ãã§ãïŒã
function sendAjax(url, data) { return new Promise(function(resolve, reject) { var req = new XMLHttpRequest(); req.open('POST', url); req.onload = function() { if (req.readyState != 4) return; if (req.status == 200) { resolve(req.response); } else { reject(Error(req.statusText)); } }; req.onerror = function() { reject(Error("Network Error")); }; req.send(data); }); } function logIt(startDate, requestId, $appendContainer) { var endDate = new Date(); var text = 'Request #' + requestId + '. Execution time: ' + ((endDate - startDate) / 1000) + 's'; var $li = document.createElement('li'); $li.textContent = text; $appendContainer.appendChild($li); } document.querySelector('.js-ajax-requests').addEventListener('click', function(e) { e.preventDefault(); var $appendContainer = e.currentTarget.nextElementSibling; for (var i = 1; i <= 8; i++) { (function(i) { var startDate = new Date(); sendAjax(REQUEST_URL + '?t=' + Math.random()).then(function() { logIt(startDate, i, $appendContainer); }); })(i); } });
ãããããã°ã€ã³ããŠãããŠãŒã¶ãŒã«é¢ããçµ±èšãããã«éä¿¡ãå§ãããšã©ããªããŸããïŒ ãã®çµæãåŸãããŸãïŒ äŸçªå·2 ïŒïŒ
ã芧ã®ãšãããçµ±èšãéä¿¡ããããã®2ã€ã®ãªã¯ãšã¹ãã¯ãµã€ãã®å
šäœçãªè² è·ã«åœ±é¿ããããŒãžãã¬ã³ããªã³ã°ããããã«ãã®ããŒã¿ãå¿
èŠãªå ŽåããŠãŒã¶ãŒã¯ä»¥åã®ãªã¯ãšã¹ãã®æéã®å®è¡æéã«çããé
延ãçµéšããŸãã
ã»ãšãã©ã®å Žåãçµ±èšããã®å¿çãåŸ
ã€ããšã¯æå³ããããŸãããããããã®èŠæ±ã¯å®è¡ã®å
šäœçãªæµãã«åœ±é¿ããŸãã ãã®ãããªç¶æ³ãé¿ããæ¹æ³ã¯ïŒ
ããŒã¿ãéä¿¡ãã
ãã§ã«HTTP / 2ã䜿çšããŠããå ŽåããŸãã¯WebSocketæ¥ç¶ãä»ããŠããŒã¿ã転éããŠããå Žåããã®åé¡ã¯ãŸã£ããåé¡ã«ãªããŸããã ãããããŸã ã§ã¯ãªãå Žåã¯ãããããHTTP / 2ã«åãæ¿ããã ãã§åœ¹ç«ã¡ãŸãïŒãããŠãæªå€¢ã®ãããªãã®ã¯ãã¹ãŠå¿ããŠããŸããŸãïŒã 幞ããªããšã«ããã¹ãŠã®ææ°ã®ãã©ãŠã¶ãŒã¯ããããµããŒãããŠããããã®ãããã³ã«ã®ãµããŒãã¯æã人æ°ã®ããWebãµãŒããŒã§ãã§ã«ç»å ŽããŠããŸãã çºçããå¯èœæ§ãããå¯äžã®åé¡ã¯ãHTTP / 1.1ã«å¯ŸããŠè¡ã£ããã¹ãŠã®ãããã³ã°ãããšãã°ãã¡ã€ã³ã·ã£ãŒãã£ã³ã°ïŒäžèŠãªTCPæ¥ç¶ãäœæããåªå
é äœä»ãã劚ããïŒãJSããã³CSSé£çµãããã³dataURIåã蟌ã¿ã€ã¡ãŒãžãåé€ããå¿
èŠãããããšã§ãã ããã«ãHTTP / 2ã«åãæ¿ãããšããµã€ãå
šäœãHTTPSã«è»¢éããå¿
èŠããããŸããããã¯ãç¹ã«HTTPçµç±ã§ãµãŒãããŒãã£ã®ãªãœãŒã¹ãã倧éã®ããŒã¿ãããŠã³ããŒãããå Žåãã³ã¹ãããããå¯èœæ§ããããŸãã
WebSocketæ¥ç¶ã䜿çšãããšããµãŒããŒãžã®æ°žç¶çãªæ¥ç¶ãååŸããããªã¯ãšã¹ãã®æ°ã«å¶éã¯ãããŸããã ãã®ãœãªã¥ãŒã·ã§ã³ã«ã¯äœãåé¡ã¯ãããŸãããããœã±ãããµãŒããŒãäžããŠã·ã¹ãã ã«æ¥ç¶ããå¿
èŠããããšããç¹ãé€ããŸã-éçºè
åãã®è¿œå äœæ¥ã ããããæçµçã«ã¯ãçµ±èšã ãã§ãªããéåžžã®ãªã¯ãšã¹ãããœã±ãããä»ããŠéä¿¡ã§ããŸãã ãããŠæãéèŠãªããš-ããã«ããããµãŒããŒããéç¥ãåä¿¡ãããã©ãã£ãã¯ãç¯çŽã§ããŸãã
ã¡ãœããçªå·1
HTTP / 2ã«åãæ¿ããæºåãã§ããŠããªãããWebSocketæ¥ç¶ã䜿çšããæºåãã§ããŠããªãå Žåãæãç°¡åãªè§£æ±ºçã¯ãçµ±èšæ
å ±ãå¥ã®ãã¡ã€ã³ã«ãªã¯ãšã¹ãããããšã§ãã ãã®åŸãåé¡ã¯æ¶ããŸãïŒ äŸçªå·3 ïŒïŒ
ãã¡ãããCORSèšå®ãå¿ããªãã§ãã ãããããããªããšããã®ãããªãªã¯ãšã¹ãã¯ãã©ãŠã¶ã«ãã£ãŠãããã¯ãããŸãã
ã¡ãœããçªå·2
Fetch APIã®æ©èœã䜿çšããŠãCookieãæž¡ããã«6ã€ã®è¿œå ãªã¯ãšã¹ããäœæã§ããŸãïŒ äŸçªå·4 ïŒã ãã ããããã¯ããªã¯ãšã¹ãã®æ¿èªã«ã¯ãããŒã䜿çšãããŠããªãå Žåã«ã®ã¿åœ¹ç«ã¡ãŸãã ããã©ã«ãã§ã¯ãFetchã¯ããããæž¡ããŸããã ããã¯å®è£
ã®ãã°ã®ããã«èŠããŸããããã®åäœã¯ChromeãšFirefoxã®äž¡æ¹ã§èŠãããŸãã ãã°æ©èœïŒ Cookieãéä¿¡ããã«ã¯ãè¿œå ã®ãã©ã¡ãŒã¿ãŒãèšå®ããå¿
èŠããããŸãã
fetch(REQUEST_URL + '?t=' + Math.random(), { method: 'POST', credentials: 'include' }).then(function () {
ããã§ãããŒã¿ããµãŒããŒã«è»¢éããæ¹æ³ã決å®ããŸããã ãã ãããŠãŒã¶ãŒã®ã¢ã¯ã·ã§ã³ããšã«ãªã¯ãšã¹ããéä¿¡ããããšã¯ãããŸããã ãã¡ãããã€ãã³ãããããã¡ãªã³ã°ããŠãããã°ã«ãŒãããµãŒããŒã«è»¢éããããšããå§ãããŸãã ãã ãããã®å ŽåããŠãŒã¶ãŒãããŒãžãé¢ãããšãèç©ããããããã¡ã倱ããªã¹ã¯ããããŸãã ãã®ãããªç¶æ³ãé¿ããæ¹æ³ã¯ïŒ
ãããã¡ãªã³ã°
ãããŠã³ã¹æ©èœã䜿çšããŠã¡ãã»ãŒãžã®ãããã¡ãªã³ã°ãæŽçã§ããŸããããã«ãããã¡ãã»ãŒãžã®éä¿¡éã®é
延ãæŽçã§ããŸãã ãã®äœæ¥ã®å°ããªäŸãããã§èŠãããšãã§ããŸã ïŒå¿
èŠã«å¿ããŠãéä¿¡ãããããŒã¿ã®ãµã€ãºãŸãã¯ãã¥ãŒã®æ倧åç¶æéãèæ
®ããŠãããè£è¶³ã§ããŸãïŒã
ãããŠã³ã¹é
延ã®äœ¿çšã«å ããŠã window.requestIdleCallbackã¡ãœããã®äœ¿çšäŸããããŸãããæ®å¿µãªããããã¹ãŠã®ãã©ãŠã¶ã§ãŸã ãµããŒããããŠããããã§ã¯ãããŸããã requestIdleCallbackã¡ãœããã¯ããã©ãŠã¶ãŒãã¢ã€ãã«ç¶æ
ã®ãšãã«å®è¡ãããé¢æ°ããã¥ãŒã«å
¥ããŸã ã ãã®æ©äŒã¯ãããšãã°çµ±èšã®éä¿¡ãããŒãžäžã®é
å»¶è² è·èŠçŽ ã®ããŒããªã©ãããã¯ã°ã©ãŠã³ãã¿ã¹ã¯ãå®è¡ããã®ã«é©ããŠããŸãã ç§ã®æèŠã§ã¯ãåæåŒã³åºããéçŽããã®ã«é©ããŠããŸãã ããšãã°ããã®äŸãåç
§ããŠãã ããã
ããã«ãã·ã¹ãã ããã€äœ¿çšå¯èœã«ãªãããå€æããŠããreadyïŒïŒã¡ãœãããåŒã³åºããšãæ®ãã®äœæ¥ããããã¯ããã«çµ±èšããµãŒããŒã«éä¿¡ããå§ããŸãã ãããŠãã®åã«ãããã¯åã«ãããã¡ã«å
¥ããããããŸããã
ã€ãã³ãé
ä¿¡ä¿èšŒ
æ®å¿µãªããããããã¡ãªã³ã°ã䜿çšãããšããã®ç¶æ³ãçºçããå¯èœæ§ããããŸãããŠãŒã¶ãŒãã¿ããéãããããåéããçµ±èšã¯éä¿¡ãããã倱ãããŸããã ããã¯åé¿ã§ããŸãã æåã«é ã«æµ®ãã¶ã®ã¯ãçµ±èšéä¿¡ãªããžã§ã¯ãã«forceïŒïŒã¡ãœãããäœæããããšã§ã ãããã¯beforeunloadã®ãšãã«å®è¡ãããŸãã ãã ããXHRãªã¯ãšã¹ãã䜿çšããŠçµ±èšãéä¿¡ããå Žåãã¿ããŸãã¯ãã©ãŠã¶ãŒãéããããšã倱æããŸãã
window.addEventListener('beforeunload', sendData, false); function sendData() { var client = new XMLHttpRequest(); client.open("POST", "/server.php", false); client.send(data); }
äžèšã®äŸã®ããã«åæãªã¯ãšã¹ããéä¿¡ããããšã§ãããä¿®æ£ã§ããŸãïŒãã ããããã«ãããã©ãŠã¶ãŒã§ãŠãŒã¶ãŒã®ã¢ã¯ã·ã§ã³ããããã¯ãããŸãïŒããŸãã¯ç¹å¥ãªsendBeaconã¡ãœããã䜿çšããŠãå°éã®ããŒã¿ãéåæã§ãµãŒããŒã«éä¿¡ããããŒãžãéããããåŸã§ãé
ä¿¡ãä¿èšŒããããšãã§ããŸã ãã®æ¹æ³ã¯ãSafariãšInternet ExplorerïŒEdgeã«ãµããŒãããããŸãïŒãé€ããã¹ãŠã®ææ°ã®ãã©ãŠã¶ãŒã§æ©èœãããããå€ãåæXHRãæ®ããŠããå¿
èŠããããŸãã ããããäž»ãªããšã¯ãã¡ãœãããéåžžã«ã³ã³ãã¯ãã§ã·ã³ãã«ã«èŠããããšã§ãã
window.addEventListener('beforeunload', sendData, false); function sendData() { var navigator = window.navigator; var url = "/server.php"; if (!navigator.sendBeacon || !navigator.sendBeacon(url, data)) { var t = new XMLHttpRequest(); t.open('POST', url, false); t.setRequestHeader('Content-Type', 'text/plain'); t.send(data); } }
ãªã¯ãšã¹ãã確å®ã«åé€ããã«ã¯ãChrome DevToolsã®[ãããã¯ãŒã¯]ã¿ããéãã[ãã®ä»]ã¿ã€ãã®ãªã¯ãšã¹ãã§ãã£ã«ã¿ãªã³ã°ããŸãã ãã¹ãŠã®sendBeaconãªã¯ãšã¹ããããã«ãããŸãã
æ®å¿µãªãããsendBeaconã«ã¯ããã€ãã®æ¬ ç¹ãããããã¹ãŠã®éä¿¡èŠæ±ãå€æããããšãã§ããŸããã ãŸããã¡ãœããã¯ãã¡ã€ã³ãããã®æ¥ç¶æ°ã®å¶éïŒ äŸçªå·5 ïŒã«è©²åœãããããçè«çã«ã¯çµ±èšãéä¿¡ãããªã¯ãšã¹ããããŒã¿ãåä¿¡ããããã®éèŠãªãªã¯ãšã¹ãããããã¯ããç¶æ³ãçºçããå ŽåããããŸãïŒãã ããäŸå€ïŒXHR-ã䜿çšããå ŽåCookieãæž¡ããã«æ°ããFetch APIãèŠæ±ãããšãsendBeaconã¯æ¥ç¶å¶éïŒ äŸçªå·9 ïŒã«è©²åœããªããªããŸãïŒã 第äºã«ãsendBeaconã§ã¯ãªã¯ãšã¹ãã®ãµã€ãºã«å¶éãããå ŽåããããŸãã ããšãã°ã以åã®Firefoxããã³Edgeã®æ倧ãªã¯ãšã¹ããµã€ãºã¯64 KBã§ããããFirefoxã®ããŒã¿ãµã€ãºã®å¶éã¯ãªããªããŸããïŒ äŸ8 ïŒã Chromeã®æ倧ããŒã¿ãµã€ãºïŒããŒãžã§ã³57ãçŸåšé¢é£ïŒãèŠã€ããããšãããšãã«ãsendBeaconã«åé¡ãåŒãèµ·ãããçµ±èšæ
å ±ãåé€ããéåžžã«èå³æ·±ããã°ãèŠã€ããŸããã äŸ7ãå®è¡ããŠããŒãžããªããŒããã äŸ8ã®çµæã確èªããŠãã ããã
Chromeã§ã¯ããããã¡ãŒã64 KBã«éãããŸã§ãæ®ãã®èŠæ±ã¯éä¿¡ã§ããŸããã ãã°ã¯ãã§ã«ä¿®æ£ãããŠãããä¿®æ£ã次ã®ããŒãžã§ã³ã«å«ãŸããããšãæåŸ
ããŠããŸãã ãã®åŸã1ã€ã®ãªã¯ãšã¹ãã®å¶éã64 KBã®ããŒã¿ã«ãªããŸãã
ãã®ããããã®ã¡ãœããã䜿çšããŠããŸããŸãªã³ã³ããŒãã³ãããå€ãã®çµ±èšæ
å ±ãååŸãããšãã»ãšãã©ã®å Žåå¶éãçºçããŸãã ãã®å¶éãè¶
ããå Žåã navigator.sendBeacon()
ã¡ãœããã¯false
ãè¿ãfalse
ããã®å Žåãéåžžã®XHRãªã¯ãšã¹ãã䜿çšãããŠãŒã¶ãŒãããŒãžãé¢ããå Žåã«ã®ã¿navigator.sendBeacon()
ãæ®ãã»ããé©åã§ãã ãŸãããã®ã¡ãœããã¯ãã€ã³ã¿ãŒãããæ¥ç¶ã倱ãããå Žåã«ãµãŒããŒãããŒã¿ãåä¿¡ããããšãä¿èšŒããŸããããã®ãããããŒã¿ãéä¿¡ãããšãã¯ã navigator.onLineããããã£ã䜿çšããããšããå§ãããŸãã
ååãšããŠãã»ãšãã©ã®å Žåã åŸè
ã®ãœãªã¥ãŒã·ã§ã³ã§ååãšæãããŸãã å¥ã®ãã¡ã€ã³ïŒ äŸ6 ïŒã«çµ±èšæ
å ±ãéä¿¡ããå Žåãç¹ã«ãã¹ã¯ãããWebã¢ããªã±ãŒã·ã§ã³ãæ€èšããŠããå Žåãäžè¬çã«ãœãªã¥ãŒã·ã§ã³ã¯ã»ãŒæ®éçã§ãã æ¥ç¶ãé »ç¹ã«å€±ãããã±ãŒã¹ãããµãŒããŒãžã®ã¡ãã»ãŒãžã®é
ä¿¡ãä¿èšŒããå¿
èŠãããã±ãŒã¹ãããã¢ãã€ã«Webãèæ
®ãããšããã®ãœãªã¥ãŒã·ã§ã³ã¯ãã¯ãé©åã§ã¯ãªããéåžžã®XHRãªã¯ãšã¹ãã䜿çšããŠãã®å®è¡çµæã確èªããããšããå§ãããŸãã
ãããããã¹ã¯ãããWebãšã¢ãã€ã«Webã®äž¡æ¹ã«é©åãããŠãããŒãµã«ãœãªã¥ãŒã·ã§ã³ã¯ãããŸããïŒ æªæ¥ãèŠãŠãæ°ããå®éšæè¡ã«ç®ãåãããšããã®ãããªæ©äŒãæ¬åœã«ååšããŸãã
Service Workerãšããã¯ã°ã©ãŠã³ãåæ
Service Workerã®ããã¯ã°ã©ãŠã³ãåæã¯ã Background Sync APIãŸãã¯å¥ã®å®è£
ã§å®æçãªåæãšããŠè¡šãããŸã ã ãã§ã«æ€èšããäŸãåãäžããŠãService Workerã®æ©èœã䜿çšããŠæžãæããŠã¿ãŸãããã
ãã®ãªã³ã¯ã§å®æãããã¹ãã±ãŒã¹ã衚瀺ã§ããŸãã ãããŠãããã«ãœãŒã¹ã³ãŒãããããŸã ã
Statistic.prototype._sendMessageToServiceWorker = function(message) { return new Promise(function(resolve, reject) { var messageChannel = new MessageChannel(); messageChannel.port1.onmessage = function(event) { if (event.data.error) { reject(event.data.error); } else { resolve(event.data); } }; navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]); }); }; Statistic.prototype._syncData = function() { return navigator.serviceWorker.ready.then(function(registration) { return registration.sync.register('oneTimeStatisticSync'); }); };
ãµãŒãã¹ã¯ãŒã«ãŒïŒ
self.addEventListener('sync', function(event) { console.info('Sync event executed'); if (event.tag == "oneTimeStatisticSync") { event.waitUntil(sendStatistic()); } });
ã芧ã®ãšãããä»åã¯ããŒã¿ãService Workerã«çŽæ¥éä¿¡ããPostMessageãä»ããŠããŒã¿ãšããåãããŸãããåæã®ã¿ãé
延ãããŸãã ãµãŒãã¹ã¯ãŒã«ãŒã®å€§ããªå©ç¹ã¯ãã€ã³ã¿ãŒãããæ¥ç¶ãçªç¶å€±ãããå ŽåãããŒã¿ã衚瀺ãããåŸã«ã®ã¿èªåçã«ããŒã¿ãéä¿¡ããããšã§ãã 以äžã®ãããªãã芧ãã ããã ãŸãã¯èªåã§ããããšããã ã€ã³ã¿ãŒãããããªãã«ããŠãäžã®äŸã®ãªã³ã¯ãã¯ãªãã¯ããã ãã§ãã æ¥ç¶ã確ç«ãããåŸã«ã®ã¿ãªã¯ãšã¹ããéä¿¡ãããããšãããããŸãã
æååæã«ç
©ãããããã³ãŒããå°ãç°¡çŽ åããããã«ãService Workerã§å©çšå¯èœãªå®æçãªåæã䜿çšã§ããŸãã æ®å¿µãªãããChrome Canaryã§ããããã¯ãŸã æ©èœãããã©ã®ããã«æ©èœããããæšæž¬ããããšããã§ããŸããã ããããä»ã§ã¯èª°ãããã®ããã«èŠªåãæžããŠããŸãïŒ
navigator.serviceWorker.register('service-worker.js') .then(function() { return navigator.serviceWorker.ready; }) .then(function(registration) { this.ready(); return registration; }.bind(this)) .then(function(registration) { if (registration.periodicSync) { registration.periodicSync.register({ tag: 'periodicStatisticSync', minPeriod: 1000 * 30, // 30sec powerState: 'auto', networkState: 'online' }); } });
å®æçãªåæã®äœ¿çšã«ãããçµ±èšãéä¿¡ã§ããã ãã§ãªããã¢ããªã±ãŒã·ã§ã³ãéã¢ã¯ãã£ãã®ãšãã«æ°ããããŒã¿ãããŠã³ããŒãããããšãã§ããŸãã ããã¯ãããšãã°ãã¥ãŒã¹ãµã€ãã®å Žåã1æéããšã«æ°ããããŒã¿ãããŠã³ããŒãããã®ã«éåžžã«äŸ¿å©ã§ãã ãã ãããã®æ©èœã¯ãŸã å©çšã§ããªããããå®æçãªåæãšã¿ã€ããŒã䜿çšããå¿
èŠããããŸãã
Service Workerã䜿çšããå Žåã®çæã¯ããããããã®æ¹æ³ããã¹ãŠã®ãã©ãŠã¶ãŒã§ãŸã ãµããŒããããŠããªããšããäºå®ã§ãã ããã«ããã®å®è£
ã«ã¯HTTPSãããã³ã«ã®ã¿ã䜿çšããå¿
èŠããããŸããServiceWorkerã¯HTTPSçµç±ã§æ¥ç¶ããå
éšã®ãã¹ãŠã®ãã§ããèŠæ±ããã®ãããã³ã«ã䜿çšããå¿
èŠããããŸãïŒäŸå€ã¯localhost
ïŒã
ãããã«
çµè«ãšããŠãWebã¢ããªã±ãŒã·ã§ã³ããã®ããŒã¿ãç£èŠããã³éä¿¡ããæ©äŒããŸããŸãå¢ããŠããããšã«æ³šç®ããããšæããŸããWebã¯ãã®æ¹åã§éåžžã«ããçºå±ããŠããŸãã ãããã£ãŠãæ¢åã®ãã©ãŠã¶æ©èœã䜿çšãããšãWebãªãœãŒã¹ããçµ±èšãå®æ§çã«åéã§ããŸãã ãŸããé©åãªåéãšåæã«ããåéããçµ±èšã«ãã£ãŠããµã€ãã®äœæ¥ãšãŠãŒã¶ãŒãšã®çžäºäœçšãããããç解ã§ããããšãå¿ããªãã§ãã ããã
ããŒã¿ã®åéã«ãæåããç¥ãããŸãïŒ