NOTE: This repository has been moved to dom-examples/service-worker/simple-service-worker
Service Worker test repository. This is a very simple demo to show basic service worker features in action.
Service Worker test repository. This is a very simple demo to show basic service worker features in action.
License: Creative Commons Zero v1.0 Universal
NOTE: This repository has been moved to dom-examples/service-worker/simple-service-worker
Service Worker test repository. This is a very simple demo to show basic service worker features in action.
My server and domain use HTTP/2 but after implement Service Worker serving site by protocol HTTP/1.1
Is any way to change it?
Service Worker not working on actual Opera Version. All others Browsers working great with my PWA.
Registration failed with SecurityError: The scope must be under the directory of the script URL.
Google Chrome 41.0.2224.3 (Official Build) dev
Revision 5bf0ab4142c6092b0bc2e54e85ffcca957f832bc-refs/branch-heads/2224@{#5}
OS Linux
Blink 537.36 (@185591)
JavaScript V8 3.31.11
But your code and the docs at
https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Recovering_failed_requests
says that caches.match
is rejected.
Using python -m http.server 8001
with Python 3.7 on Windows 10 to start a simple server as described will result in the following message printed on to the console in Firefox 74.0:
Registration failed with SecurityError: The operation is insecure.
Using Chrome, you can get the following additional information:
Registration failed with SecurityError: Failed to register a ServiceWorker for scope ('http://localhost:8001/sw-test/') with script ('http://localhost:8001/sw-test/sw.js'): The script has an unsupported MIME type ('text/plain').
It seems like the Python http.server
module is unable to use the correct mimetypes in the HTTP response for JavaScript files. Also, the content types of the other JavaScript files are text/plain
as well in the HTTP response, as for example in the response of app.js:
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.7.4
Date: Thu, 19 Mar 2020 19:27:39 GMT
Content-type: text/plain
Content-Length: 2143
Last-Modified: Thu, 19 Mar 2020 19:24:15 GMT
The content types of the JPEG images seem to be okay.
If you experience the same problem, starting a server using the Python script at https://gist.github.com/HaiyangXu/ec88cbdce3cdbac7b8d5 works for me.
This isn't a real issue but more a question about your service worker: why would you need to clone the response on line 28? I would have written it like this:
.then(function(response) {
caches.open('v1').then(function(cache) {
cache.put(event.request, response);
});
return response;
})
Any thoughts about this?
from here: https://github.com/mdn/sw-test/blob/gh-pages/sw.js#L37
Can someone help me out?
I didn't find a better place to ask this, but why service workers doesn't work in Firefox if i have history disabled?
In https://github.com/mdn/sw-test/blob/gh-pages/sw.js, the call to cache.addAll()
throws an exception when trying to add /sw-test/gallery to the cache. Link is a 404, and responses with an error type are not supported by cache.add methods.
This forces the service worker installation to fail on Firefox (which is correct according to the current specs: https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#installation-algorithm).
As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:
If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].
(Message COC001)
Hello, keep getting the following in the console, even after deploying to https and enabling experimental web platform features: Registration failed with TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script.
Here is the site: https://jaysonvdw.github.io/
Please assist
I have dynamic content which one change something on website like number of sold items. I'm displaying number of orders on web page based on database connection. When number change I don't see this updated content and after second time reload page updated number is show. For example if customers see number 0 of orders and another customer order item then first one which one seen 0 at first visit next time he will see again 0 order even if real counter will be much higher than 0 because he get cached website from first visit. This Service Worker is maybe good for static context not for dynamical. Is there any way to disable caching DIV content?
This Service Workers required disable uMatrix.
Whats is the purpose of this project? It´s running but what do this?
OS: Linux Fedora
Chrome: Version 75.0.3770.100 (Official Build) (64-bit)
Python 2
Ran...
python -m SimpleHTTPServer 8001
chrome: http://localhost:8001/sw-test/
Didn't work.
I removed the "/sw-test/" from the URL and it at least loaded the demo.
Still got 404 error for the service worker.
In app.js I edited line 4 to remove /sw-test/ from the URI and then the slashes from 'scope'.
navigator.serviceWorker.register('sw.js', { scope: 'sw-test' }).then(function (reg) {
In sw.js I edited lines 5 - 12 to remove the '/sw-test/':
'index.html', 'style.css', 'app.js', 'image-list.js', 'star-wars-logo.jpg', 'gallery/bountyHunters.jpg', 'gallery/myLittleVader.jpg', 'gallery/snowTroopers.jpg'
After those edits it worked.
Hi All,
Not sure what is the issue here. The SN registration is failing with the below message
"Registration failed with SecurityError: Failed to register a ServiceWorker for scope ('https://www.ctx.com/sw-test/') with script ('https://www.ctx.com/sw-test/sw.js'): The script has an unsupported MIME type ('text/html')."
Has anyone encountered the above message or has some clue on this?
I think the last commit broke the example - in the sw.js file, where is event
supposed to come from? Shouldn't that be inside of a on('fetch')?
Thanks,
Kerry
I couldn't make service workers work. Probably because I haven't figured out how to use HTTPS on my local development environment.
If this is the reason I couldn't make service workers work, it would be nice if a readme could mention this requirement.
Hello, I am getting this error all the time, related to the sw.js. I´m not sure what else I can do:
tello-asd.github.io/:1 Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://tello-asd.github.io/') with script ('https://tello-asd.github.io/sw.js'): ServiceWorker script evaluation failed
Here is my web:
https://tello-asd.github.io/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.