service-worker

Service worker not returning offline page is returning default page

这一生的挚爱 提交于 2021-01-29 07:33:03
问题 I have a service worker that I want to return an offline page if you're offline. I realized you have to cache the offline page first, so I did that. When I had it cached, and I used chrome dev tools to throttle the network to offline, it showed the default offline page! I don't know how to bring up the page when it is offline. I'm on a chromebook if that would change anything. Here's my code (by the way I am completely new to service workers): this.addEventListener('install', function(event)

Why isn't my offline cached subdomain page not loading when called from other subdomain?

强颜欢笑 提交于 2021-01-29 06:50:31
问题 Quick question: I have a service worker that caches a page from subdomain "domainB.project.company.com" Expl: domainB.project.company.com/mypage.html This works, I can see the assets + html being cached in my Chrome Dev Tools. Then I have another subdomain "domainA.project.company.com" with a page domainA.project.company.com/hello.html so, both pages have the same host... Now: the mypage.html is fully cached. Why - when offline - isn't the "mypage.html" shown when navigating to that url from

Progressive Web App (PWA) redirect page into standalone mode

北战南征 提交于 2021-01-29 03:20:10
问题 I have PWA and I can run it as standalone (if user clicks icon on a device) or I can run as normal website (if user enter URL directly into web browser). Is it possible to redirect page (open as standalone) if user open it as non standalone? My manifest file already contain standalone parameter: "display": "standalone" I need something to start with. 回答1: As far as I know you need to "install" the pwa on the user device first. By clicking the icon on the device (meaning you already installed

Changing application server key in push manager subscription

随声附和 提交于 2021-01-28 10:50:35
问题 I implemented web push notifications using service worker. I collected user subscriptions with a particular application server key. Suppose if we change the application server key, then when we get the subscription using "reg.pushManager.getSubscription()", we will get the old subscription information which was created using the old application server key. How to handle this scenario? How to get the new subscription from the user? 回答1: Get the subscription using reg.pushManager

Changing application server key in push manager subscription

早过忘川 提交于 2021-01-28 10:43:18
问题 I implemented web push notifications using service worker. I collected user subscriptions with a particular application server key. Suppose if we change the application server key, then when we get the subscription using "reg.pushManager.getSubscription()", we will get the old subscription information which was created using the old application server key. How to handle this scenario? How to get the new subscription from the user? 回答1: Get the subscription using reg.pushManager

angular 6 service worker dataGroups not working

对着背影说爱祢 提交于 2021-01-28 08:11:06
问题 Hi I am trying to deploy a background Service worker that makes calls to api in some time interval in this case 3s, but it seams not to work, when I go to application I am getting no requests to server. My data group in ngsw-config.json stands: "dataGroups": [ { "name": "app-service-list", "urls": [ "http://localhost:5000/api/TcpCommunication/GetCabinsService" ], "cacheConfig": { "maxSize": 5, "maxAge": "3s", "strategy": "performance" } } ] And when I do http-server -p 8090 web page works,

react scripts build service worker not caching custom files

爱⌒轻易说出口 提交于 2021-01-28 07:03:53
问题 It has come to my attention that the service worker generated by the react-scrips build does not cache certain files. Those files include (in my project) a custom css file in the public folder and some files accessed from other servers (such as google fonts and bootstrap css files). How do I make sure that those files are cached too? Thank you alot EDIT: So the react build script generates the service-worker.js file in /build. The generated service worker does not work as wished however. The

Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html') Vue js?

≯℡__Kan透↙ 提交于 2021-01-28 05:58:19
问题 I want to include service worker in my vue js project and i did this before with my simple HTML projects in which it works really great but when i include the same file to my vue js code it keeps throwing the error The script has an unsupported MIME type ('text/html'). index.js?3609:11 Service wroker: error: SecurityError: Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html'). here is the code which i used for ragister my service worker if (navigator

Keep track of progress while precaching assets with the Workbox

泪湿孤枕 提交于 2021-01-28 03:12:39
问题 Imagine we have N assets that need to be pre-cached with a service-worker once user navigated to the web site. We have appropriate precache-manifest.js with listed N-files and we are using workbox.precaching.precacheAndRoute([...]) to configure needed behavior (default CRA setup) Is there a way to keep track of precaching progress when using workbox.precaching.precacheAndRoute or workbox.precaching.precache? I imagine it could be something like passing a parameter-callback function to the

How to allow cookies and handle 302 redirects with workbox service worker tools?

℡╲_俬逩灬. 提交于 2021-01-28 02:43:23
问题 I have a SSR based react app and at present implementing Workbox tools for precaching and offline capabilities into it. I ran into issues mainly because the site relies on cookies at server side and issues redirects based on these. Initial load works fine, but once service worker(sw) is online and another refresh results in sw doing a fetch call with the url from within workbox source. During this time, the server doesn't find cookies(fetch doesn't carry credentials - link) and issues a