LoginSignup
16
9

More than 5 years have passed since last update.

【React】create-react-appのregisterServiceWorkerとは、なんぞや

Last updated at Posted at 2017-12-04

create-react-appのregisterServiceWorkerについて

いくらググっても情報がなくて、灯台下暗しで、registerServiceWorker.jsのファイルを開いてみるとコメントが書いてあった。

registerServiceWorker.js
// 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.

ってことで、キャッシュしてるってことです。詳しくは、
https://goo.gl/KwvDNy
ここを見なさい、とあるので、見ると。。。
本番時は必要みたいですが、開発時はキャッシュしてほしくないのでコメントしちゃっても良さそうです。

import { unregister } from './registerServiceWorker';

まだ勉強中なのでよくわかってませんが、確実に消すには
こんな感じで書くとキャッシュを消してくれる?ってことかな?

ということで、「registerServiceWorker」とは?と検索しても日本語の説明がなかったので残しておきます。

16
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
9