// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the “N+1” visit to a page, since previously
// cached resources are updated in the background.
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.
service worker是在后臺(tái)運(yùn)行的一個(gè)線程,可以用來處理離線緩存、消息推送、后臺(tái)自動(dòng)更新等任務(wù)。registerServiceWorker就是為react項(xiàng)目注冊(cè)了一個(gè)service worker,用來做資源的緩存,這樣你下次訪問時(shí),就可以更快的獲取資源。而且因?yàn)橘Y源被緩存,所以即使在離線的情況下也可以訪問應(yīng)用(此時(shí)使用的資源是之前緩存的資源)。注意,registerServiceWorker注冊(cè)的service worker 只在生產(chǎn)環(huán)境中生效(process.env.NODE_ENV === ‘production’)