Cache images via service worker
Improves the image request logic by making it possible to check if an image is cached. In case an image is cached, it does not need to be put into the image queue because it won't be sent to the server.
This commit is contained in:
@@ -14,20 +14,8 @@ import '@/index.css';
|
||||
import '@/lib/PointerDeviceUtil.ts';
|
||||
import { StrictMode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
||||
import { App } from '@/App';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.unregister().catch(defaultPromiseErrorHandler('unregister service workers'));
|
||||
if (caches) {
|
||||
caches.keys().then(async (names) => {
|
||||
await Promise.all(names.map((name) => caches.delete(name)));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const container = document.getElementById('root');
|
||||
const root = createRoot(container!);
|
||||
root.render(
|
||||
|
||||
Reference in New Issue
Block a user