{"action":"created","comment":{"url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/comments/54619156","id":54619156,"diff_hunk":"@@ -1,103 +1,127 @@\n-(function(self){\n-  var CACHE_PREFIX = '__wp-sw-cache::';\n+(function(self, localforage){\n \n-  var CACHE_NAME = CACHE_PREFIX + '$name';\n-  var CACHE_FILES = $files;\n+  // Represents the name of both storage and serviceworker\n+  // This shouldn't change because the SW code below is smart enough to\n+  // update what's needed and delete what isn't\n+  var storageKey = '$name';\n \n-  var debug = $debug;\n+  // Outputs messages to the JS console if desired\n+  var log = function() {\n+    if($debug) {\n+      console.log.apply(console, arguments);\n+    }\n+  };\n \n-  self.addEventListener('install', function(event) {\n-    // Perform install step:  loading each required file into cache\n-    event.waitUntil(\n-      caches.open(CACHE_NAME)\n-        .then(function(cache) {\n-          // Add all offline dependencies to the cache\n-          if (debug) {\n-            console.log('[install] Caches opened, adding all core components to cache');\n-          }\n-          return cache.addAll(CACHE_FILES);\n-        })\n-        .then(function() {\n-          if (debug) {\n-            console.log('[install] All required resources have been cached, we\\'re good!');\n-          }\n-          return self.skipWaiting();\n-        })\n-    );\n-  });\n+  var wpSwCache = self.wpSwCache = {\n+    // A { url: hash } object which will be used to populate cache\n+    // A changed url object will ensure the SW is downloaded when URLs change\n+    urls: $urls,","path":"wp-sw-cache/lib/service-worker.js","position":42,"original_position":42,"commit_id":"5416613f523e28ba717635ce5a977ef7a11c610d","original_commit_id":"5416613f523e28ba717635ce5a977ef7a11c610d","user":{"login":"staabm","id":120441,"avatar_url":"https://avatars.githubusercontent.com/u/120441?v=3","gravatar_id":"","url":"https://api.github.com/users/staabm","html_url":"https://github.com/staabm","followers_url":"https://api.github.com/users/staabm/followers","following_url":"https://api.github.com/users/staabm/following{/other_user}","gists_url":"https://api.github.com/users/staabm/gists{/gist_id}","starred_url":"https://api.github.com/users/staabm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staabm/subscriptions","organizations_url":"https://api.github.com/users/staabm/orgs","repos_url":"https://api.github.com/users/staabm/repos","events_url":"https://api.github.com/users/staabm/events{/privacy}","received_events_url":"https://api.github.com/users/staabm/received_events","type":"User","site_admin":false},"body":"Looks like a php leftover","created_at":"2016-03-01T19:17:03Z","updated_at":"2016-03-01T19:17:03Z","html_url":"https://github.com/darkwing/wp-sw-cache/pull/40#discussion_r54619156","pull_request_url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40","_links":{"self":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/comments/54619156"},"html":{"href":"https://github.com/darkwing/wp-sw-cache/pull/40#discussion_r54619156"},"pull_request":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40","id":61129541,"html_url":"https://github.com/darkwing/wp-sw-cache/pull/40","diff_url":"https://github.com/darkwing/wp-sw-cache/pull/40.diff","patch_url":"https://github.com/darkwing/wp-sw-cache/pull/40.patch","issue_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/40","number":40,"state":"open","locked":false,"title":"Adding more efficient caching mechanism so entire caches aren't deleted for one file change","user":{"login":"darkwing","id":46655,"avatar_url":"https://avatars.githubusercontent.com/u/46655?v=3","gravatar_id":"","url":"https://api.github.com/users/darkwing","html_url":"https://github.com/darkwing","followers_url":"https://api.github.com/users/darkwing/followers","following_url":"https://api.github.com/users/darkwing/following{/other_user}","gists_url":"https://api.github.com/users/darkwing/gists{/gist_id}","starred_url":"https://api.github.com/users/darkwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkwing/subscriptions","organizations_url":"https://api.github.com/users/darkwing/orgs","repos_url":"https://api.github.com/users/darkwing/repos","events_url":"https://api.github.com/users/darkwing/events{/privacy}","received_events_url":"https://api.github.com/users/darkwing/received_events","type":"User","site_admin":false},"body":"The problem with the current version of wp-sw-cache is that deletes an entire cache when only one file/url changes, which isn't good.  This update checks served hashes against localforage hashes and only updates the stuff that has changed.","created_at":"2016-02-29T19:23:00Z","updated_at":"2016-03-01T19:17:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"179987d1a23a71813f5c2a33a3b2a2d53bffcfe7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40/commits","review_comments_url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40/comments","review_comment_url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/comments{/number}","comments_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/40/comments","statuses_url":"https://api.github.com/repos/darkwing/wp-sw-cache/statuses/5416613f523e28ba717635ce5a977ef7a11c610d","head":{"label":"darkwing:efficient-cache-hash","ref":"efficient-cache-hash","sha":"5416613f523e28ba717635ce5a977ef7a11c610d","user":{"login":"darkwing","id":46655,"avatar_url":"https://avatars.githubusercontent.com/u/46655?v=3","gravatar_id":"","url":"https://api.github.com/users/darkwing","html_url":"https://github.com/darkwing","followers_url":"https://api.github.com/users/darkwing/followers","following_url":"https://api.github.com/users/darkwing/following{/other_user}","gists_url":"https://api.github.com/users/darkwing/gists{/gist_id}","starred_url":"https://api.github.com/users/darkwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkwing/subscriptions","organizations_url":"https://api.github.com/users/darkwing/orgs","repos_url":"https://api.github.com/users/darkwing/repos","events_url":"https://api.github.com/users/darkwing/events{/privacy}","received_events_url":"https://api.github.com/users/darkwing/received_events","type":"User","site_admin":false},"repo":{"id":50134240,"name":"wp-sw-cache","full_name":"darkwing/wp-sw-cache","owner":{"login":"darkwing","id":46655,"avatar_url":"https://avatars.githubusercontent.com/u/46655?v=3","gravatar_id":"","url":"https://api.github.com/users/darkwing","html_url":"https://github.com/darkwing","followers_url":"https://api.github.com/users/darkwing/followers","following_url":"https://api.github.com/users/darkwing/following{/other_user}","gists_url":"https://api.github.com/users/darkwing/gists{/gist_id}","starred_url":"https://api.github.com/users/darkwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkwing/subscriptions","organizations_url":"https://api.github.com/users/darkwing/orgs","repos_url":"https://api.github.com/users/darkwing/repos","events_url":"https://api.github.com/users/darkwing/events{/privacy}","received_events_url":"https://api.github.com/users/darkwing/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/darkwing/wp-sw-cache","description":"This WordPress plugin provides a method for caching theme assets via a service worker.","fork":false,"url":"https://api.github.com/repos/darkwing/wp-sw-cache","forks_url":"https://api.github.com/repos/darkwing/wp-sw-cache/forks","keys_url":"https://api.github.com/repos/darkwing/wp-sw-cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/darkwing/wp-sw-cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/darkwing/wp-sw-cache/teams","hooks_url":"https://api.github.com/repos/darkwing/wp-sw-cache/hooks","issue_events_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/events{/number}","events_url":"https://api.github.com/repos/darkwing/wp-sw-cache/events","assignees_url":"https://api.github.com/repos/darkwing/wp-sw-cache/assignees{/user}","branches_url":"https://api.github.com/repos/darkwing/wp-sw-cache/branches{/branch}","tags_url":"https://api.github.com/repos/darkwing/wp-sw-cache/tags","blobs_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/darkwing/wp-sw-cache/statuses/{sha}","languages_url":"https://api.github.com/repos/darkwing/wp-sw-cache/languages","stargazers_url":"https://api.github.com/repos/darkwing/wp-sw-cache/stargazers","contributors_url":"https://api.github.com/repos/darkwing/wp-sw-cache/contributors","subscribers_url":"https://api.github.com/repos/darkwing/wp-sw-cache/subscribers","subscription_url":"https://api.github.com/repos/darkwing/wp-sw-cache/subscription","commits_url":"https://api.github.com/repos/darkwing/wp-sw-cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/darkwing/wp-sw-cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/darkwing/wp-sw-cache/contents/{+path}","compare_url":"https://api.github.com/repos/darkwing/wp-sw-cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/darkwing/wp-sw-cache/merges","archive_url":"https://api.github.com/repos/darkwing/wp-sw-cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/darkwing/wp-sw-cache/downloads","issues_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues{/number}","pulls_url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls{/number}","milestones_url":"https://api.github.com/repos/darkwing/wp-sw-cache/milestones{/number}","notifications_url":"https://api.github.com/repos/darkwing/wp-sw-cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/darkwing/wp-sw-cache/labels{/name}","releases_url":"https://api.github.com/repos/darkwing/wp-sw-cache/releases{/id}","deployments_url":"https://api.github.com/repos/darkwing/wp-sw-cache/deployments","created_at":"2016-01-21T20:22:04Z","updated_at":"2016-02-25T00:34:03Z","pushed_at":"2016-03-01T18:57:36Z","git_url":"git://github.com/darkwing/wp-sw-cache.git","ssh_url":"git@github.com:darkwing/wp-sw-cache.git","clone_url":"https://github.com/darkwing/wp-sw-cache.git","svn_url":"https://github.com/darkwing/wp-sw-cache","homepage":null,"size":117,"stargazers_count":16,"watchers_count":16,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":16,"default_branch":"master"}},"base":{"label":"darkwing:master","ref":"master","sha":"6ef84200058155ec317c25da9286983a8914eed1","user":{"login":"darkwing","id":46655,"avatar_url":"https://avatars.githubusercontent.com/u/46655?v=3","gravatar_id":"","url":"https://api.github.com/users/darkwing","html_url":"https://github.com/darkwing","followers_url":"https://api.github.com/users/darkwing/followers","following_url":"https://api.github.com/users/darkwing/following{/other_user}","gists_url":"https://api.github.com/users/darkwing/gists{/gist_id}","starred_url":"https://api.github.com/users/darkwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkwing/subscriptions","organizations_url":"https://api.github.com/users/darkwing/orgs","repos_url":"https://api.github.com/users/darkwing/repos","events_url":"https://api.github.com/users/darkwing/events{/privacy}","received_events_url":"https://api.github.com/users/darkwing/received_events","type":"User","site_admin":false},"repo":{"id":50134240,"name":"wp-sw-cache","full_name":"darkwing/wp-sw-cache","owner":{"login":"darkwing","id":46655,"avatar_url":"https://avatars.githubusercontent.com/u/46655?v=3","gravatar_id":"","url":"https://api.github.com/users/darkwing","html_url":"https://github.com/darkwing","followers_url":"https://api.github.com/users/darkwing/followers","following_url":"https://api.github.com/users/darkwing/following{/other_user}","gists_url":"https://api.github.com/users/darkwing/gists{/gist_id}","starred_url":"https://api.github.com/users/darkwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkwing/subscriptions","organizations_url":"https://api.github.com/users/darkwing/orgs","repos_url":"https://api.github.com/users/darkwing/repos","events_url":"https://api.github.com/users/darkwing/events{/privacy}","received_events_url":"https://api.github.com/users/darkwing/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/darkwing/wp-sw-cache","description":"This WordPress plugin provides a method for caching theme assets via a service worker.","fork":false,"url":"https://api.github.com/repos/darkwing/wp-sw-cache","forks_url":"https://api.github.com/repos/darkwing/wp-sw-cache/forks","keys_url":"https://api.github.com/repos/darkwing/wp-sw-cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/darkwing/wp-sw-cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/darkwing/wp-sw-cache/teams","hooks_url":"https://api.github.com/repos/darkwing/wp-sw-cache/hooks","issue_events_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/events{/number}","events_url":"https://api.github.com/repos/darkwing/wp-sw-cache/events","assignees_url":"https://api.github.com/repos/darkwing/wp-sw-cache/assignees{/user}","branches_url":"https://api.github.com/repos/darkwing/wp-sw-cache/branches{/branch}","tags_url":"https://api.github.com/repos/darkwing/wp-sw-cache/tags","blobs_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/darkwing/wp-sw-cache/statuses/{sha}","languages_url":"https://api.github.com/repos/darkwing/wp-sw-cache/languages","stargazers_url":"https://api.github.com/repos/darkwing/wp-sw-cache/stargazers","contributors_url":"https://api.github.com/repos/darkwing/wp-sw-cache/contributors","subscribers_url":"https://api.github.com/repos/darkwing/wp-sw-cache/subscribers","subscription_url":"https://api.github.com/repos/darkwing/wp-sw-cache/subscription","commits_url":"https://api.github.com/repos/darkwing/wp-sw-cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/darkwing/wp-sw-cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/darkwing/wp-sw-cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/darkwing/wp-sw-cache/contents/{+path}","compare_url":"https://api.github.com/repos/darkwing/wp-sw-cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/darkwing/wp-sw-cache/merges","archive_url":"https://api.github.com/repos/darkwing/wp-sw-cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/darkwing/wp-sw-cache/downloads","issues_url":"https://api.github.com/repos/darkwing/wp-sw-cache/issues{/number}","pulls_url":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls{/number}","milestones_url":"https://api.github.com/repos/darkwing/wp-sw-cache/milestones{/number}","notifications_url":"https://api.github.com/repos/darkwing/wp-sw-cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/darkwing/wp-sw-cache/labels{/name}","releases_url":"https://api.github.com/repos/darkwing/wp-sw-cache/releases{/id}","deployments_url":"https://api.github.com/repos/darkwing/wp-sw-cache/deployments","created_at":"2016-01-21T20:22:04Z","updated_at":"2016-02-25T00:34:03Z","pushed_at":"2016-03-01T18:57:36Z","git_url":"git://github.com/darkwing/wp-sw-cache.git","ssh_url":"git@github.com:darkwing/wp-sw-cache.git","clone_url":"https://github.com/darkwing/wp-sw-cache.git","svn_url":"https://github.com/darkwing/wp-sw-cache","homepage":null,"size":117,"stargazers_count":16,"watchers_count":16,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40"},"html":{"href":"https://github.com/darkwing/wp-sw-cache/pull/40"},"issue":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/40"},"comments":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/darkwing/wp-sw-cache/statuses/5416613f523e28ba717635ce5a977ef7a11c610d"}}}}