{"action":"created","issue":{"url":"https://api.github.com/repos/ctrlplusb/react-universally/issues/511","repository_url":"https://api.github.com/repos/ctrlplusb/react-universally","labels_url":"https://api.github.com/repos/ctrlplusb/react-universally/issues/511/labels{/name}","comments_url":"https://api.github.com/repos/ctrlplusb/react-universally/issues/511/comments","events_url":"https://api.github.com/repos/ctrlplusb/react-universally/issues/511/events","html_url":"https://github.com/ctrlplusb/react-universally/issues/511","id":262481026,"number":511,"title":"Bundle fails to load after server restart","user":{"login":"tijs","id":3108,"avatar_url":"https://avatars3.githubusercontent.com/u/3108?v=4","gravatar_id":"","url":"https://api.github.com/users/tijs","html_url":"https://github.com/tijs","followers_url":"https://api.github.com/users/tijs/followers","following_url":"https://api.github.com/users/tijs/following{/other_user}","gists_url":"https://api.github.com/users/tijs/gists{/gist_id}","starred_url":"https://api.github.com/users/tijs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tijs/subscriptions","organizations_url":"https://api.github.com/users/tijs/orgs","repos_url":"https://api.github.com/users/tijs/repos","events_url":"https://api.github.com/users/tijs/events{/privacy}","received_events_url":"https://api.github.com/users/tijs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-10-03T15:48:19Z","updated_at":"2017-10-23T14:58:59Z","closed_at":null,"author_association":"NONE","body":"In the current setup it seems the nonce used for the CSP setup is being re-created for each server restart. The effect of this is that people who navigate the site with a bundle created before the restart suddenly find themselves with an invalid javascript file (according to the Content Security Policy) after the restart of the server. This is not ideal so i was wondering if anyone else has run into this and perhaps found a fix?\r\n\r\nI imagine it's possible to invalidate the cached bundles when the server has restarted somehow so the clients fetch new bundles which would then have the new nonce and would not be blocked by the CSP rules. But i'm not quite sure how i can force the client cache to clear just on server restarts."},"comment":{"url":"https://api.github.com/repos/ctrlplusb/react-universally/issues/comments/338687375","html_url":"https://github.com/ctrlplusb/react-universally/issues/511#issuecomment-338687375","issue_url":"https://api.github.com/repos/ctrlplusb/react-universally/issues/511","id":338687375,"user":{"login":"diondirza","id":10954870,"avatar_url":"https://avatars3.githubusercontent.com/u/10954870?v=4","gravatar_id":"","url":"https://api.github.com/users/diondirza","html_url":"https://github.com/diondirza","followers_url":"https://api.github.com/users/diondirza/followers","following_url":"https://api.github.com/users/diondirza/following{/other_user}","gists_url":"https://api.github.com/users/diondirza/gists{/gist_id}","starred_url":"https://api.github.com/users/diondirza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diondirza/subscriptions","organizations_url":"https://api.github.com/users/diondirza/orgs","repos_url":"https://api.github.com/users/diondirza/repos","events_url":"https://api.github.com/users/diondirza/events{/privacy}","received_events_url":"https://api.github.com/users/diondirza/received_events","type":"User","site_admin":false},"created_at":"2017-10-23T14:58:59Z","updated_at":"2017-10-23T14:58:59Z","author_association":"CONTRIBUTOR","body":"I leave it with default handle of offline plugin versioning for now, and just add cache control middleware in the server. Here is my code for cache middleware\r\n\r\n```\r\nfunction cacheHandler(req, res, next) {\r\n  const caches = [\r\n    {\r\n      regex: /.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|woff)$/i,\r\n      value: `public, max-age=${getSeconds('1y')}`,\r\n    },\r\n    {\r\n      regex: /.(jpg|jpeg|png|gif|swf|svg)$/i,\r\n      value: `public, max-age=${getSeconds('30d')}`,\r\n    },\r\n    {\r\n      regex: /.(txt|xml)$/i,\r\n      value: `public, max-age=${getSeconds('3d')}`,\r\n    },\r\n    {\r\n      regex: /.(js|css)$/i,\r\n      value: `max-age=${getSeconds('1y')}`,\r\n    },\r\n    {\r\n      regex: /.(html?)$/i,\r\n      value: 'max-age=0, no-store, no-cache, must-revalidate',\r\n    },\r\n    {\r\n      regex: /sw.js$/i,\r\n      value: 'no-store, no-cache, must-revalidate',\r\n    },\r\n  ];\r\n\r\n  caches.forEach((cache) => {\r\n    if (req.url.match(cache.regex)) {\r\n      res.setHeader('Cache-Control', cache.value);\r\n      return true;\r\n    }\r\n    return false;\r\n  });\r\n\r\n  next();\r\n}\r\n```"}}
{"actor":{"display_login":"diondirza"}}