{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/UniformDocs/issues/357","repository_url":"https://api.github.com/repos/Starcounter/UniformDocs","labels_url":"https://api.github.com/repos/Starcounter/UniformDocs/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/UniformDocs/issues/357/comments","events_url":"https://api.github.com/repos/Starcounter/UniformDocs/issues/357/events","html_url":"https://github.com/Starcounter/UniformDocs/pull/357","id":350415280,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4MjcxNDY2","number":357,"title":"Discussion PR: create ServiceWorker middleware","user":{"login":"alshakero","id":17054134,"node_id":"MDQ6VXNlcjE3MDU0MTM0","avatar_url":"https://avatars3.githubusercontent.com/u/17054134?v=4","gravatar_id":"","url":"https://api.github.com/users/alshakero","html_url":"https://github.com/alshakero","followers_url":"https://api.github.com/users/alshakero/followers","following_url":"https://api.github.com/users/alshakero/following{/other_user}","gists_url":"https://api.github.com/users/alshakero/gists{/gist_id}","starred_url":"https://api.github.com/users/alshakero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alshakero/subscriptions","organizations_url":"https://api.github.com/users/alshakero/orgs","repos_url":"https://api.github.com/users/alshakero/repos","events_url":"https://api.github.com/users/alshakero/events{/privacy}","received_events_url":"https://api.github.com/users/alshakero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-08-14T12:54:19Z","updated_at":"2018-09-06T09:11:51Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/Starcounter/UniformDocs/pulls/357","html_url":"https://github.com/Starcounter/UniformDocs/pull/357","diff_url":"https://github.com/Starcounter/UniformDocs/pull/357.diff","patch_url":"https://github.com/Starcounter/UniformDocs/pull/357.patch"},"body":"_This PR is not intended to be merged. It's just to use GH GUI to diff and discuss._\r\n\r\n**I created a new middleware that does two jobs:** \r\n1. The same job as regular `PartialToStandaloneHtmlProvider`: delivers the app shell.\r\n2. Handles requests to `/sw.js` and gives you a service worker that has a unique key within representing the cached files. This key changes when you restart the app, thus invalidating the service worker cache. \r\n\r\n**Caveat:**\r\n\r\nYou need to refresh the page to know that you have to invalidate the cache, by the time you know you invalidated it, you already consumed its files, you need yet another refresh. So it takes 2 refreshes after the app restart to get the fresh content.\r\n\r\n**Possible solutions:**\r\n\r\nLuckily, after the **first** refresh, an event is fired that new content is available in the service worker, so we could either programmatically reload the page there without waiting for user input, or we could display some UI like `palindrom-error-catcher` saying \"New content available, please refresh\". \r\n\r\n**How to try it:**\r\n1. Run the app from `Add-service-worker-middleware` branch.\r\n2. Go to http://localhost:8080/UniformDocs/\r\n3. Restart the app.\r\n4. Refresh the page and watch the console, you should see \"New content is available; please refresh.\".\r\n\r\nRelated to https://github.com/Starcounter/StarcounterClientFiles/pull/110"},"comment":{"url":"https://api.github.com/repos/Starcounter/UniformDocs/issues/comments/419022880","html_url":"https://github.com/Starcounter/UniformDocs/pull/357#issuecomment-419022880","issue_url":"https://api.github.com/repos/Starcounter/UniformDocs/issues/357","id":419022880,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTAyMjg4MA==","user":{"login":"warpech","id":566463,"node_id":"MDQ6VXNlcjU2NjQ2Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/566463?v=4","gravatar_id":"","url":"https://api.github.com/users/warpech","html_url":"https://github.com/warpech","followers_url":"https://api.github.com/users/warpech/followers","following_url":"https://api.github.com/users/warpech/following{/other_user}","gists_url":"https://api.github.com/users/warpech/gists{/gist_id}","starred_url":"https://api.github.com/users/warpech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warpech/subscriptions","organizations_url":"https://api.github.com/users/warpech/orgs","repos_url":"https://api.github.com/users/warpech/repos","events_url":"https://api.github.com/users/warpech/events{/privacy}","received_events_url":"https://api.github.com/users/warpech/received_events","type":"User","site_admin":false},"created_at":"2018-09-06T09:11:51Z","updated_at":"2018-09-06T09:11:51Z","author_association":"MEMBER","body":"Using `http://localhost:8080` in Chrome 69, on a clean cache, I get plenty of exceptions in console:\r\n\r\n![capture3](https://user-images.githubusercontent.com/566463/45147609-9a49c680-b1c5-11e8-98c9-ba7e6f5533af.PNG)\r\n"}}
{"actor":{"display_login":"warpech"}}