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

Question: is this compatible with PSK out of the box? #6

Open
chwzr opened this issue Jan 2, 2018 · 4 comments
Open

Question: is this compatible with PSK out of the box? #6

chwzr opened this issue Jan 2, 2018 · 4 comments
Labels

Comments

@chwzr
Copy link

chwzr commented Jan 2, 2018

I know its not the propper place to ask questions, but is this element compatible and working out of the box with the Polymer starter Kit Service-Worker implementation?

At mine it does not trigger the updatefound event, even if I change something at sw-precache-config.js or directly at the generated service-worker.js...
e.g. chaning the cacheId from 001 to 002 and then build + deploy the changes. Nothing happens on page reload.. but when I go to dev tools application tab, and click update on the service worker, the toast shows up, and then on page reload the new content shows up..

I guess the boilerplate for registering the service worker (inside index.html of the PSK) is not enough?

Maybe changing documentation if some more lines of code is needed to fire the updatefound event?

Kind Regards,

Chwzr

@chwzr
Copy link
Author

chwzr commented Jan 2, 2018

I've found out that its not an issue with the service worker registering or the PSK implementation or your Element:
For those hosting on Firebase, the Cache-Control header cache-control:max-age=3600 is set to one hour, so for apps in development you can use this snippet inside your firebase.json's hosting Object to disable caching for the service worker at all:

"headers": [{
  "source" : "service-worker.js",
  "headers" : [{
    "key" : "Cache-Control",
    "value" : "max-age=0"
  }]
}]

In a production environment, however, one should rethink the importance of the app's up-to-dateness for the sake of LIGHTSPEED page load times and adjust it back to one hour ;-)

Maybe its worth a little line in the documentation, but it's your choice!
Please close this issue.
Thx for this awesome element!

@morbidick
Copy link
Owner

Oh yeah good find, thats a point i struggled with too and would be a good addition to the readme (since we already have a section on registering an sw). I'll leave this open to track the issue until its added to the docs.

@morbidick morbidick added the docs label Jan 2, 2018
@veith
Copy link
Contributor

veith commented Jan 3, 2018

Why do you use service worker during development?

The polymer starter kit service-worker.js says:
'Service worker disabled for development, will be generated at build time.'

@chwzr
Copy link
Author

chwzr commented Jan 3, 2018

Yes but at development time you also have to test your build (with the service worker which is generated at build time, not the dummy one in the source folder which only logs this line)

And when its critical for your app to be up to date, you also need a fresh service worker with fresh document hashes to purge the old documents in cache ;)

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

No branches or pull requests

3 participants