Open ridvandev opened 5 years ago
I realized that i don't cache the root '/'. And this document says i have to cache it. I don't know if it is the cause of my issue.
https://github.com/NekR/offline-plugin/blob/master/docs/examples/SPA.md
Here is the problem: If i cache root, my .Net Core Mvc controller action '/Home/Index' is not invoked when site loads. But i need to invoke it every first website load.
Any idea?
I tried ServiceWorker.navigateFallbackURL property but it doesn't work either.
Here is the latest Offline-Plugin config i tried:
new OfflinePlugin({
externals: [
'/android-chrome-192x192.png',
'/android-chrome-256x256.png',
'/android-chrome-512x512.png',
'/apple-touch-icon.png',
'/favicon.ico',
'/favicon-16x16.png',
'/favicon-32x32.png',
'/mstile-150x150.png',
'/safari-pinned-tab.svg',
'/dist/vendor.js',
'/dist/vendor.css',
'/offline.html'
],
ServiceWorker: {
publicPath: '/sw.js',
output: '../sw.js',
navigateFallbackURL: '/offline.html',
events: true
},
AppCache: {
publicPath: '/',
directory: '../',
FALLBACK: {
'/': '/offline.html'
},
events: true
}
})
@rcturk Sorry for the late reply.
navigateFallbackURL
is deprecated, see the appShell
option instead. It should do what you need.Please report back if it works or not.
Thanks for the reply @GGAlanSmithee
I tried appShell option. But, appShell navigates all requests to '/offline.html' instead of fallback requests when i configure appShell: '/offline.html' .
I can't achieve navigating to '/offline.html' when user doesn't have connection. Here is the latest plugin config.
new OfflinePlugin({
externals: [
'/android-chrome-192x192.png',
'/android-chrome-256x256.png',
'/android-chrome-512x512.png',
'/apple-touch-icon.png',
'/favicon.ico',
'/favicon-16x16.png',
'/favicon-32x32.png',
'/mstile-150x150.png',
'/safari-pinned-tab.svg',
'/dist/vendor.js',
'/dist/vendor.css',
'/offline.html'
],
ServiceWorker: {
publicPath: '/sw.js',
output: '../sw.js',
events: true
},
appShell: '/',
AppCache: {
publicPath: '/',
directory: '../',
FALLBACK: {
'/': '/offline.html'
},
events: true
}
})
I implemented Offline-Plugin to my .NET Core based React Single Page website.
Here is the config:
Here is the sw.js output's first part:
And last, manifest.appcache file:
So i am not sure my configs are true but it is working as expected except 'offline.html' fallback. When i tried developer tools offline mode, i see below:
I could not achieve to navigate to /offline.html. What should i do?