I know that you can create WebSocket connections inside the Service Worker itself; my question is, can you really use WebSocket from your application in normal mode and request WebSocket requests to intercept / cache Service Worker in the same way as you can do for regular HTTP fetch requests?
Here's an example of intercepting and caching a regular HTTP request from Service Worker.
self.addEventListener('fetch', function(event) {
event.respondWith(caches.match(event.request));
});
How to configure Service Worker if all my requests were through WebSockets?
source
share