Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !2276

Provide a no-op SW that will be served by the dev environment.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/jeffposnick/no-op-sw into master May 20, 2017
  • Overview 6
  • Commits 2
  • Pipelines 0
  • Changes 4

Created by: jeffposnick

R: @gaearon @Timer

This adds in a "no-op" service-worker.js at the root of the dev environment's web server.

It works around the issue of someone serving their dev and prod environments from the same port and ending up with a production service worker that controls their dev environment.

If a user finds themselves in that situation, then the next time the browser checks for an updated service worker, the "no-op" version will be installed instead, and immediately force any open pages to reload, so that they're once again talking directly to the dev server.

(The caveat here is that, as with all things service worker-y, this assumes that build/service-worker.js was served using reasonable cache headers. I took a look at how the recommended serve module responds to requests for the build/service-worker.js, and it does appear to use a very short cache lifetime, so that's good!)

Fixes #2272 (closed)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jeffposnick/no-op-sw