{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments/66169645","id":66169645,"diff_hunk":"@@ -24,24 +26,28 @@\n </head>\n <body>\n \n-  <!-- #### Basic Usage -->\n+  <!-- #### Installing the Service Worker -->\n   <!--\n-  amp-install-serviceworker should have both properties `src` and `data-iframe-src`; `src` is the location of Service Worker to be installed when the original AMP pages is accessed, `data-iframe-src` is the location of HTML file which calls Service Worker installation process when the cached AMP pages is accessed.\n-  The reason why the latter option is required is because browsers can't install Service Worker from other domains for security reasons. For details of the security considerations of Service Worker, [see official specs](https://www.w3.org/TR/service-workers/#security-considerations).\n+  `amp-install-serviceworker` should have both properties `src` and `data-iframe-src` set; `src` is the location of service worker to be installed when the original AMP pages is accessed, `data-iframe-src` is the location of HTML file which calls service worker installation process when the cached AMP pages is accessed.\n+  The reason why the latter option is required is because browsers can't install service worker from other domains for security reasons. For details of the security considerations of service worker, [see official specs](https://www.w3.org/TR/service-workers/#security-considerations).\n+\n+  One thing to note: the iframe installing the service worker will only be injected if the page is open longer than 20s.\n   -->\n   <amp-install-serviceworker\n       src=\"/sw.js\"\n       data-iframe-src=\"https://ampbyexample.com/sw.html\"\n       layout=\"nodisplay\">\n   </amp-install-serviceworker>\n   <!--\n-  <p class=\"card warning\">`sw.js` here is generated using [sw-precache](https://github.com/GoogleChrome/sw-precache), which generates a [Service Worker JavaScript file](https://ampbyexample.com/sw.js) that caches specified static files. See example in the repository of `sw-precache` and [gulpfile.js](https://github.com/ampproject/amp-by-example/blob/master/gulpfile.js) for how to use it.</p> In this sample, when users access this AMP page for the 2nd time, the Service Worker is installed and start caching all image files and video files under root path of this domain.\n+  <p class=\"card warning\">The service worker in this sample ([sw.js](https://ampbyexample.com/sw.js)) is generated using [sw-precache](https://github.com/GoogleChrome/sw-precache). With sw-precache you can generate service worker code that will precache specific resources.</p> \n+  \n+  In this sample, when users access this AMP page for the 2nd time, the service worker is installed and start caching all image files and video files under root path of this domain.\n   \n-  In order to confirm if the Service Worker is installed and it is working as expected, follow the procedure below:\n+  In order to confirm if the service worker is installed and it is working as expected, follow the procedure below:\n   1. Access to https://ampbyexample.com/components/amp-install-serviceworker/ twice.\n-  2. Open Chrome Dev Tools and navigate to \"Resources\" tab. You may see \"Service Workers\" section and see `/sw.js` is installed.\n-  3. Then open \"Cached Storage\". You'll find a lot of files whose names start with \"sw-precache-v1--\", which are cached images and videos.\n-  4. Disable your network connection and reload this page. It still works! On \"Network\" tab in Dev Tools, you'll find \"(from ServiceWorker)\" notation in the rows of image/video file fetch events.  \n+  2. Open Chrome Dev Tools and navigate to \"Resources\" tab. In the \"Service Workers\" section you can see that `/sw.js` is installed.\n+  3. Then open \"Cached Storage\". You'll find a lot of files whose names start with `sw-precache-v1--`, these are the cached images and videos.\n+  4. Disable your network connection and reload this page. It still works! In the \"Network\" tab in Dev Tools, you'll find see which resources are cached by the service worker. \n   -->","path":"src/20_Components/amp-install-serviceworker.html","position":59,"original_position":59,"commit_id":"b1c6ffcc767bfcebb2c463328263543eec927572","original_commit_id":"b1c6ffcc767bfcebb2c463328263543eec927572","user":{"login":"jmadler","id":435158,"avatar_url":"https://avatars.githubusercontent.com/u/435158?v=3","gravatar_id":"","url":"https://api.github.com/users/jmadler","html_url":"https://github.com/jmadler","followers_url":"https://api.github.com/users/jmadler/followers","following_url":"https://api.github.com/users/jmadler/following{/other_user}","gists_url":"https://api.github.com/users/jmadler/gists{/gist_id}","starred_url":"https://api.github.com/users/jmadler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmadler/subscriptions","organizations_url":"https://api.github.com/users/jmadler/orgs","repos_url":"https://api.github.com/users/jmadler/repos","events_url":"https://api.github.com/users/jmadler/events{/privacy}","received_events_url":"https://api.github.com/users/jmadler/received_events","type":"User","site_admin":false},"body":"Might make sense to add a note to some blogpost that explains how SWs can be used for things other than caching docs for offline access.","created_at":"2016-06-07T23:19:00Z","updated_at":"2016-06-07T23:19:00Z","html_url":"https://github.com/ampproject/amp-by-example/pull/176#discussion_r66169645","pull_request_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments/66169645"},"html":{"href":"https://github.com/ampproject/amp-by-example/pull/176#discussion_r66169645"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176"}}},"pull_request":{"url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176","id":72529004,"html_url":"https://github.com/ampproject/amp-by-example/pull/176","diff_url":"https://github.com/ampproject/amp-by-example/pull/176.diff","patch_url":"https://github.com/ampproject/amp-by-example/pull/176.patch","issue_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/176","number":176,"state":"open","locked":false,"title":"Cosmetic changes to install-service-worker","user":{"login":"sebastianbenz","id":380472,"avatar_url":"https://avatars.githubusercontent.com/u/380472?v=3","gravatar_id":"","url":"https://api.github.com/users/sebastianbenz","html_url":"https://github.com/sebastianbenz","followers_url":"https://api.github.com/users/sebastianbenz/followers","following_url":"https://api.github.com/users/sebastianbenz/following{/other_user}","gists_url":"https://api.github.com/users/sebastianbenz/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastianbenz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastianbenz/subscriptions","organizations_url":"https://api.github.com/users/sebastianbenz/orgs","repos_url":"https://api.github.com/users/sebastianbenz/repos","events_url":"https://api.github.com/users/sebastianbenz/events{/privacy}","received_events_url":"https://api.github.com/users/sebastianbenz/received_events","type":"User","site_admin":false},"body":"* disable pre-cache verbose mode\r\n* add links to sw docs\r\n* add links to supported browsers\r\n* some rephrasing","created_at":"2016-06-03T15:51:19Z","updated_at":"2016-06-07T23:19:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c413530052ccdb924656ed09a14829d301810976","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176/commits","review_comments_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176/comments","review_comment_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/176/comments","statuses_url":"https://api.github.com/repos/ampproject/amp-by-example/statuses/b1c6ffcc767bfcebb2c463328263543eec927572","head":{"label":"ampproject:sw","ref":"sw","sha":"b1c6ffcc767bfcebb2c463328263543eec927572","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":51327024,"name":"amp-by-example","full_name":"ampproject/amp-by-example","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amp-by-example","description":"A hands-on introduction to Accelerated Mobile Pages (AMP) focusing on code and live samples.","fork":false,"url":"https://api.github.com/repos/ampproject/amp-by-example","forks_url":"https://api.github.com/repos/ampproject/amp-by-example/forks","keys_url":"https://api.github.com/repos/ampproject/amp-by-example/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amp-by-example/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amp-by-example/teams","hooks_url":"https://api.github.com/repos/ampproject/amp-by-example/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amp-by-example/events","assignees_url":"https://api.github.com/repos/ampproject/amp-by-example/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amp-by-example/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amp-by-example/tags","blobs_url":"https://api.github.com/repos/ampproject/amp-by-example/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amp-by-example/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amp-by-example/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amp-by-example/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amp-by-example/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amp-by-example/languages","stargazers_url":"https://api.github.com/repos/ampproject/amp-by-example/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amp-by-example/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amp-by-example/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amp-by-example/subscription","commits_url":"https://api.github.com/repos/ampproject/amp-by-example/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amp-by-example/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amp-by-example/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amp-by-example/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amp-by-example/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amp-by-example/merges","archive_url":"https://api.github.com/repos/ampproject/amp-by-example/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amp-by-example/downloads","issues_url":"https://api.github.com/repos/ampproject/amp-by-example/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amp-by-example/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amp-by-example/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amp-by-example/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amp-by-example/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amp-by-example/deployments","created_at":"2016-02-08T21:05:29Z","updated_at":"2016-06-06T15:56:26Z","pushed_at":"2016-06-07T22:30:44Z","git_url":"git://github.com/ampproject/amp-by-example.git","ssh_url":"git@github.com:ampproject/amp-by-example.git","clone_url":"https://github.com/ampproject/amp-by-example.git","svn_url":"https://github.com/ampproject/amp-by-example","homepage":"http://ampbyexample.com/","size":44967,"stargazers_count":115,"watchers_count":115,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":47,"forks":49,"open_issues":47,"watchers":115,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"50c3f6716783c50db03f74c00970b5489041fe9d","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":51327024,"name":"amp-by-example","full_name":"ampproject/amp-by-example","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amp-by-example","description":"A hands-on introduction to Accelerated Mobile Pages (AMP) focusing on code and live samples.","fork":false,"url":"https://api.github.com/repos/ampproject/amp-by-example","forks_url":"https://api.github.com/repos/ampproject/amp-by-example/forks","keys_url":"https://api.github.com/repos/ampproject/amp-by-example/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amp-by-example/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amp-by-example/teams","hooks_url":"https://api.github.com/repos/ampproject/amp-by-example/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amp-by-example/events","assignees_url":"https://api.github.com/repos/ampproject/amp-by-example/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amp-by-example/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amp-by-example/tags","blobs_url":"https://api.github.com/repos/ampproject/amp-by-example/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amp-by-example/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amp-by-example/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amp-by-example/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amp-by-example/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amp-by-example/languages","stargazers_url":"https://api.github.com/repos/ampproject/amp-by-example/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amp-by-example/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amp-by-example/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amp-by-example/subscription","commits_url":"https://api.github.com/repos/ampproject/amp-by-example/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amp-by-example/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amp-by-example/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amp-by-example/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amp-by-example/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amp-by-example/merges","archive_url":"https://api.github.com/repos/ampproject/amp-by-example/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amp-by-example/downloads","issues_url":"https://api.github.com/repos/ampproject/amp-by-example/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amp-by-example/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amp-by-example/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amp-by-example/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amp-by-example/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amp-by-example/deployments","created_at":"2016-02-08T21:05:29Z","updated_at":"2016-06-06T15:56:26Z","pushed_at":"2016-06-07T22:30:44Z","git_url":"git://github.com/ampproject/amp-by-example.git","ssh_url":"git@github.com:ampproject/amp-by-example.git","clone_url":"https://github.com/ampproject/amp-by-example.git","svn_url":"https://github.com/ampproject/amp-by-example","homepage":"http://ampbyexample.com/","size":44967,"stargazers_count":115,"watchers_count":115,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":47,"forks":49,"open_issues":47,"watchers":115,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176"},"html":{"href":"https://github.com/ampproject/amp-by-example/pull/176"},"issue":{"href":"https://api.github.com/repos/ampproject/amp-by-example/issues/176"},"comments":{"href":"https://api.github.com/repos/ampproject/amp-by-example/issues/176/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/176/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amp-by-example/statuses/b1c6ffcc767bfcebb2c463328263543eec927572"}}}}
{"actor":{"display_login":"jmadler"}}