Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a service worker using Workbox #191

Merged
merged 2 commits into from
Jul 20, 2018

Conversation

jeffposnick
Copy link
Contributor

Hey @romannurik!

If you're cool with it, this PR will add a service worker that precaches all of the critical static content, and then sets up some runtime caching for the third-party Google Fonts and Analytics requests.

You can test it out at https://jeffposnick.github.io/AndroidAssetStudio/

(It doesn't add a web app manifest or handle Add to Homescreen prompts, but that could be done in a follow-up if you're open to it.)

CC: @PaulKinlan

@romannurik
Copy link
Owner

Hey Jeffy thanks for doing this!

My only concern was in @PaulKinlan's CL on another app of mine, it seemed to break browsersync reload. Would this PR have the same issue?

@jeffposnick
Copy link
Contributor Author

I just pushed out another commit that does two things:

  • Uses separate ports for dev and prod, creating two origins. That means the service worker/cache from one environment won't effect the service worker/cache from the other.

  • Put in a dummy, no-op sw.js that's used in the dev environment, so even though it will be registered, it won't intercept network traffic. That should make browsersync happy.

browsersync won't work as expected in the prod environment with the real service worker, because the service worker will intercept requests and used cached responses, but that will match the real-world behavior.

@romannurik
Copy link
Owner

This is perfect thanks Jeffy!

@romannurik romannurik merged commit 5848f23 into romannurik:master Jul 20, 2018
@romannurik
Copy link
Owner

I'll see about doing another release soon that'll include this.

@jeffposnick jeffposnick deleted the workbox branch July 23, 2018 21:03
@jeffposnick
Copy link
Contributor Author

Sweet! Thanks for building awesome web apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants