NekR / offline-plugin

Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
MIT License
4.51k stars 294 forks source link

AppCache events only fire once #210

Open enzoaeneas opened 7 years ago

enzoaeneas commented 7 years ago

The code within manifest.html removes the events after five seconds (cleanuptimer) and does not reattch them. My application may be updated at anytime while the browser is running, and I need to notify my users that an update is ready. Currently events will only fire when the application is loaded.

NekR commented 7 years ago

I see, thank for reporting it. PR is welcome to fix that (since you already figured out what the code does).

enzoaeneas commented 7 years ago

I'll take a look this weekend at how to get the options into the templated manifest.html code and then submit a PR.

On Tue, Mar 21, 2017, 19:06 Arthur Stolyar notifications@github.com wrote:

I see, thank for reporting it. PR is welcome to fix that (since you already figured out what the code does).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NekR/offline-plugin/issues/210#issuecomment-288246912, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6KGcV2U41a_dKb7LgGUyTZ7da4bHsdks5roFfagaJpZM4MkYiY .

-- Kevin James

NekR commented 7 years ago

@enzoaeneas okay, thank you! Feel free to ask questions if something won't be clear.

jampy commented 7 years ago

IMHO that 5000 ms timeout effectively prevents any Application Cache events after 5000ms. So, if the application takes longer than 5 seconds to download, no UpdateReady is ever fired.

Unfortunately Application Cache is still very important for PWAs, because not all browsers support Service Workers, yet...

enzoaeneas commented 7 years ago

Wow. It's been a month since I looked at this. I'll work on the pull-request and get it submitted :-P

On Tue, Apr 25, 2017 at 4:22 PM jampy notifications@github.com wrote:

IMHO that 5000 ms timeout effectively prevents any Application Cache events after 5000ms. So, if the application takes longer than 5 seconds to download, no UpdateReady is ever fired.

  • what's the point in cleaning up anyway? It obviously makes sense to stop that 50ms interval, but why run also removeEventListener? I guess those three event listeners takes up less space in memory than the code that removes them. ;-)
  • why is the interval needed? Looks like a polyfill or something similar. Are there browsers that don't provide event listeners for application cache?

Unfortunately Application Cache is still very important for PWAs, because not all browsers support Service Workers, yet...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NekR/offline-plugin/issues/210#issuecomment-297153502, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6KGX07oa-3ZXVj5na96Zk0VDzuYnWgks5rzlYWgaJpZM4MkYiY .

-- Kevin James

NekR commented 7 years ago

@enzoaeneas There is already a PR, see: https://github.com/NekR/offline-plugin/pull/241

jampy commented 7 years ago

@enzoaeneas: do you have a chance to test #248?

enzoaeneas commented 7 years ago

Let me see if I can get to it today. I'm working on a different projec nowt, but I am still primary on the other. I test in Chrome latest and IE

  1. I may be able to get Safari.

On Wed, May 3, 2017 at 1:36 AM jampy notifications@github.com wrote:

@enzoaeneas https://github.com/enzoaeneas: do you have a chance to test

248 https://github.com/NekR/offline-plugin/pull/248?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NekR/offline-plugin/issues/210#issuecomment-298826784, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6KGVLPoUTq_28xQ9HOl5deng6J9Saxks5r2BJ4gaJpZM4MkYiY .

-- Kevin James

NekR commented 7 years ago

I found some of my notes regarding AppCache statuses/events (on macOS) (posting here instead of in the #248 PR to be to find it easier):

/*
  UNCACHED = 0;
  IDLE = 1;
  CHECKING = 2;
  DOWNLOADING = 3;
  UPDATEREADY = 4;
_____________________

  # No Update
    * Chrome: 2, 1
    * Safari: 2, 1
    * Firefox: 2, 1

    * Chrome events: checking, noupdate
    * Safari events: checking, noupdate
    * Firefox events: noupdate

  # Has Update
    * Chrome: 2, then 4
    * Safari: 2, sometimes 3, then 4
    * Firefox: 4, 2, 3, 1, 3, 4

    * Chrome events: checking, progress, updateready
    * Safari events: checking, downloading, progress, updateready
    * Firefox events: downloading, progress

  # First install
    * Chrome: 2, 3, 1
    * Safari: 0, 3, 1
    * Firefox: 0, 1

    * Chrome events: checking, downloading, progress, cached
    * Safari events:  checking, downloading, progress, cached
    * Firefox events: checking, downloading, progress, cached

  # Manifest error
    * Chrome: 2, 5
    * Safari: 2, 5
    * Firefox: 1, 2, 5

    * Chrome events: checking, obsolete
    * Safari events: checking, obsolete
    * Firefox events: checking, obsolete

  # Manifest error when not installed
    * Chrome: 2, 0
    * Safari: 0
    * Firefox: 0

    * Chrome events: checking, error
    * Safari events: checking, error
    * Firefox events: checking, error
*/
NekR commented 7 years ago

That one excludes IE/Edge, but AFAIR it has similar to Chrome events/statuses, I just didn't test it a lot in IE/Edge.

jampy commented 7 years ago

@NekR: completely missed this since I was waiting for a reply in the PR.

Anyway, could you please explain what this stuff means? Thanks.