GithubHelp home page GithubHelp logo

Comments (26)

NekR avatar NekR commented on August 20, 2024 4

I fixed it as a separate project: https://github.com/NekR/self-destroying-sw

from offline-plugin.

ericfong avatar ericfong commented on August 20, 2024 1

Personally, I disabled appcache when I use offline-plugin.

Try to respond 404 for your appcache file

from offline-plugin.

NekR avatar NekR commented on August 20, 2024 1

Hi @GGAlanSmithee. Sorry, I don't have time to review it at a moment. I'll take a look later today or tomorrow.

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

Why exactly it's needed? There is no way to uninstall AppCache for example. Also calling registration.unregister() doesn't mean that ServiceWorker will became redundant immediately, so you shouldn't clear cache at that moment. Clearing cache may result in broken page (potentially), but in case of offline-plugin this simply will make SW cache subsequent requests again.

from offline-plugin.

ericfong avatar ericfong commented on August 20, 2024

Sorry, I am new to this area. Just finding a way to nicely uninstall service worker and cache.

I know app-cache is hard to uninstall. So, I disabled it.

But I think we should have a way to revert the app to a normal mode in case anything happened.

Can we launch a sw.js with a empty caches first and use registration.unregister() & caches.delete

Or do we have any reference steps to nicely uninstall service worker and caches?

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

But I think we should have a way to revert the app to a normal mode in case anything happened.

What for example?

Or do we have any reference steps to nicely uninstall service worker and caches?

There is no special way to "truly uninstall" ServiceWorker. Since SW is a scriptable thing, correct uninstallation depends on its implementation.
I think good way to handle it to send a message to SW telling it to "unregister". Then SW will put itself in inert state (will stop handling any request), will delete all its caches and then will unregister itself (registration.unregister()).

But I still do not see any special reason to have this API. Even if there is some sense in it, it won't be in priority in many next releases, because there are more important things right now.

But i'll keep this open and if you have any reason for this API to exists, please leave them here. Any feedback is welcome. Thanks!

from offline-plugin.

ericfong avatar ericfong commented on August 20, 2024

Thanks a lot.

Because I get some clients report that they cannot get the new version when
I setup AppCache on my own.

So, I want to try Service Worker and disable AppCache

And I found that it is pretty hard to remove a buggy AppCache (because it
throw exception in downloading assets...)

So, I wonder how can we have a mechanism to disable all clients using
service worker before I launch it.

I think that is Edge case too. Thx for you help

On 12 June 2016 at 12:41, Arthur Stolyar [email protected] wrote:

But I think we should have a way to revert the app to a normal mode in
case anything happened.

What for example?

Or do we have any reference steps to nicely uninstall service worker and
caches?

There is no special way to "truly uninstall" ServiceWorker. Since SW is a
scriptable thing, correct uninstallation depends on its implementation.
I think good way to handle it to send a message to SW telling it to
"unregister". Then SW will put itself in inert state (will stop handling
any request), will delete all its caches and then will unregister itself (
registration.unregister()).

But I still do not see any special reason to have this API. Even if there
is some sense in it, it won't be in priority in many next releases, because
there are more important things right now.

But i'll keep this open and if you have any reason for this API to exists,
please leave them here. Any feedback is welcome. Thanks!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#62 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAOd5HXfLpeVGbQyPgHgBLhrub2nRT5Fks5qK43ngaJpZM4IuZK0
.

Best Regards,
Eric Fong

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

I think that is Edge case too. Thx for you help

Sounds like a good reason actually. I'll think if I can do something here.

And I found that it is pretty hard to remove a buggy AppCache (because it
throw exception in downloading assets...)

Serving 404 HTTP status for manifest.appcache should help I think. Have you tried it?

from offline-plugin.

ericfong avatar ericfong commented on August 20, 2024

I solve by serve a empty manifest.appcache and force download new index.html from server

and index.html should without manifest tag

But I am not sure about Service Worker. And there may be a better way.

from offline-plugin.

chaintng avatar chaintng commented on August 20, 2024

Can you explain a bit more?
I want to completely remove serviceworker and appcache.
I want customer to no longer able to access offline.

But i don't know where to start with. Should i disable appcache or serviceworker or both of them?

Can you please advise?

from offline-plugin.

chaintng avatar chaintng commented on August 20, 2024

I tried above code and now service worker get uninstlled.
However, Safari browser can still access my website without internet connection.
How can i disallow that? Is it because of AppCache?

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

How can i disallow that? Is it because of AppCache?

Yes, it's because of AppCache. Just delete manifest.appcache (but leave manifest.html) there to remove it from browsers.

I want customer to no longer able to access offline.

As a feature or you have problems with offline support?

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

I think I can add uninstall option in v4, just would be good to hear reason why you possibly want to disable offline-support.

@ericfong yeah, AppCache should go away 👍 Some people still use it though

from offline-plugin.

chaintng avatar chaintng commented on August 20, 2024

@NekR it's because i accidently use offline plugin during development process
And now, tester cannot get latest version of my update because their device load assets from cache instead.
That's why i want to remove it completely.

from offline-plugin.

chaintng avatar chaintng commented on August 20, 2024

response 404 work quite well,
Thanks man!

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

That's why i want to remove it completely.

I see. Thanks for the info, @chaintan17.
I think that it would be good to have uninstall option or at least a doc about how to uninstall. Thanks all for contributing ideas 👍

from offline-plugin.

GGAlanSmithee avatar GGAlanSmithee commented on August 20, 2024

I had some issues with a sw interfering when trying to run my app in dev mode. The sw made it so that hot-module-replacement would not work (the app was running in prod mode). When ctrl+f5, the browsers would refresh and enable HMR, but the next time I re-started the app, it would go back to using the sw.

There are probably some factors which makes this an edge case:

  1. I am running the app from cloud9 IDE (so localhost is proxied via a URL using https)
  2. I installed sw "locally", in production mode, for testing purposes

Anyway, I just wanted to say that the only way I could resolve this was by navigating to chrome://serviceworker-internals/ and uninstalling the sw that way. Maybe we should add this as a way to truly uninstall a sw in the documentation?

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

So you mean that you once run your project in production env on localhost and SW worked there. Then you switched back to development env still running on localhost and that previously registered SW was messing with you dev env? (assuming you have offline-plugin disabled in dev env)

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

@GGAlanSmithee ^

from offline-plugin.

GGAlanSmithee avatar GGAlanSmithee commented on August 20, 2024

@NekR

So you mean that you once run your project in production env on localhost and SW worked there. Then you switched back to development env still running on localhost and that previously registered SW was messing with you dev env? (assuming you have offline-plugin disabled in dev env)

exactly!

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

@GGAlanSmithee I see. I'll think how to handle this situation. Thanks for letting me know about it!

from offline-plugin.

NekR avatar NekR commented on August 20, 2024

@GGAlanSmithee would it help if you could install SW in development environment too, but it wouldn't handle requests, it would just be there?

from offline-plugin.

GGAlanSmithee avatar GGAlanSmithee commented on August 20, 2024

@NekR I'm not sure if this is something that offline-plugin should handle or if it was something situational that I did which caused it. Now that I successfully uninstalled the sw, I will see if I can reproduce it.

from offline-plugin.

GGAlanSmithee avatar GGAlanSmithee commented on August 20, 2024

@NekR

I can reproduce this by:

  1. uninstall sw in chrome://serviceworker-internals
  2. run app in development mode
    • no sw installed
    • HMR (and other dev-only features) are enabled
  3. run app in production mode
    • sw is installed and resources cached
  4. run app in development mode
    • app looks for sw
    • cannot find cached content (is removed in a clean script)
    • HMR (and other dev-only features) are disabled
  5. uninstall sw and run app in development mode and everything works again

Here is where it gets weird, because if I (instead of doing point 5) do the following;

  1. clear the cache with ctrl+f5
  2. close the tab
  3. open the app in a new tab (in development mode)

then, a cached version of the production build get served, which shows the service worker events and the caching of content (in dev mode which doesn't even install the sw, and without an actual sw file)!, If I then hit ctrl+f5 again, then the dev build gets served. I can reproduce this over and over.

This is super weird, but I cannot see what I am doing wrong. Here's some additional info:

"offline-plugin": "^4.3.1",

new OfflinePlugin({
    relativePaths: false,
    publicPath: output.publicPath,

    ServiceWorker: {
        events: true,
        navigateFallbackURL: '/'
    },

    // No need to cache .htaccess. See http://mxs.is/googmp,
    // this is applied before any match in `caches` section
    excludes: ['.htaccess'],

    caches: {
        main: ['/', ':rest:'],

        // All chunks marked as `additional`, loaded after main section
        // and do not prevent SW to install. Change to `optional` if
        // do not want them to be preloaded at all (cached only when first loaded)
        additional: ['*.chunk.js', '/reset.css']
    },

    externals: ['/', '/reset.css'],

    // Removes warning for about `additional` section usage
    safeToUseOptionalCaches: true,

    AppCache: false
})

it builds on the one from react-boilerplate and is only included in the prod build.

I have a feeling this error is caused be me running my app through cloud9 ide which servers it over https, but my knowledge of sw is very limited, so might be totally wrong.

Sorry for the lack of info. If I'm able to get some more time, I will try to create a minimal repo for you.

from offline-plugin.

GGAlanSmithee avatar GGAlanSmithee commented on August 20, 2024

Thinking some more about it, I guess it isn't that weird. Chrome looks for a sw, since there is one registered for that address. But shouldn't the behavior be the same for localhost then?

from offline-plugin.

danny-wang avatar danny-wang commented on August 20, 2024

@NekR
Every time I update something in my code and I deploy. When a user opens my site again he'll only fetch the new service worker, but still use the old cached files. This is until he refreshes a second time...

Therefore, every time I deploy something new, ask a friend to check it out, he won't see it the first time he tries to open it...
Any ideas how to prevent this?

i hope service worker find update can prevent page show info until get new file, can use new file to render info

from offline-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.