electron: [Bug]: ServiceWorker cannot cache custom scheme URLs
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
v19.0.9
What operating system are you using?
Other Linux
Operating System Version
Gentoo
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Register custom scheme:
electron.protocol.registerSchemesAsPrivileged([
{
'app',
privileges: {
standard: true,
secure: true,
allowServiceWorkers: true,
bypassCSP: true,
supportFetchAPI: true,
corsEnabled: true,
stream: true,
},
},
])
In the Service Worker:
const cache = await self.caches.open('myCache')
const response = await fetch(request)
cache.put(request, response)
Expected that the cache can store the URL.
Actual Behavior
With the url app://index.html/b/test the fetch works perfectly but cache.put returns an error:
TypeError: Failed to execute 'put' on 'Cache': Request scheme 'app' is unsupported
Testcase Gist URL
No response
Additional Information
No response
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 6
- Comments: 22 (5 by maintainers)
🪄 unstale
bump
Bump and this stale bot is counterproductive.
@MarshallOfSound I think that it’s relatively safe to add cacheing of alternate handlers specific to electron.
The protocol handler already registers schemas as privileged - it would be useful to add another flag to the privileged list like
isConsideredHttpFamilyor even more strictlycacheableThis would just allow service workers to cache these assets, which would be pretty nice
I don’t know why it would be necessary to block caching non-http schemes. Maybe the original check was thinking that the only non-http scheme a browser would see is a file:// scheme, or similar.