Comments (26)
I fixed it as a separate project: https://github.com/NekR/self-destroying-sw
from offline-plugin.
Personally, I disabled appcache when I use offline-plugin.
Try to respond 404 for your appcache file
from offline-plugin.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
@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.
response 404 work quite well,
Thanks man!
from offline-plugin.
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.
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:
- I am running the app from cloud9 IDE (so localhost is proxied via a URL using https)
- 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.
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.
from offline-plugin.
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.
@GGAlanSmithee I see. I'll think how to handle this situation. Thanks for letting me know about it!
from offline-plugin.
@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.
@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.
I can reproduce this by:
- uninstall sw in
chrome://serviceworker-internals
- run app in development mode
- no sw installed
- HMR (and other dev-only features) are enabled
- run app in production mode
- sw is installed and resources cached
- 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
- 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;
- clear the cache with
ctrl+f5
- close the tab
- 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.
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.
@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)
- Question - SW caching all assets site-wide HOT 1
- In Angular 9, files inside directories are not being cached
- Ideas for Documentation to Help with Troubleshooting
- Some files missing in cache on SW first load/install HOT 1
- Caching subpath urls
- Caching fails to download assets in Chrome 85 HOT 1
- Issue with default path
- [question] Having Multiple runtime installations
- Problem with Webpack 5.0 HOT 17
- Micro Front-ends structure with single-spa
- Auto update doesn't work
- After removing redux-offline, how do we ensure that client's who have old versions get the latest update?
- `onInstalling` doesn't seem to be called, because `ignoreInstalling` is always true
- offline-plugin does not serve assets from service worker
- Webpack 5 compatibility HOT 3
- The "path" argument must be of type string. Received undefined HOT 4
- Cache Images from AWS S3
- Pass ServiceWorker version to the install events
- Terser Plugin issue while building with webpack-cli HOT 3
- upgrade ejs package | CVE-2022-29078 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from offline-plugin.