Agressively cache favicons fetched via icons.duckduckgo.com; Fall back to regular icon if image can't be loaded at all
This commit is contained in:
parent
0d8a6fc7aa
commit
7b1e7c68ad
|
@ -91,7 +91,9 @@ export class ItemIcon extends LitElement {
|
|||
|
||||
render() {
|
||||
return html`
|
||||
${this._favIcon ? html` <img .src=${this._favIcon} /> ` : html` <pl-icon .icon=${this._icon}></pl-icon> `}
|
||||
${this._favIcon
|
||||
? html` <img .src=${this._favIcon} @error=${() => (this._favIcon = undefined)} /> `
|
||||
: html` <pl-icon .icon=${this._icon}></pl-icon> `}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,19 @@
|
|||
declare var self: ServiceWorkerGlobalScope;
|
||||
|
||||
import { precacheAndRoute } from "workbox-precaching";
|
||||
import { registerRoute } from "workbox-routing";
|
||||
import { CacheFirst } from "workbox-strategies";
|
||||
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
|
||||
// Aggressively cache favicons fetched via icons.duckduckgo.com
|
||||
registerRoute(
|
||||
({ request }) => request.url.startsWith("https://icons.duckduckgo.com"),
|
||||
new CacheFirst({
|
||||
cacheName: "image-cache",
|
||||
})
|
||||
);
|
||||
|
||||
self.addEventListener("message", (event) => {
|
||||
const action = event.data && event.data.type;
|
||||
|
||||
|
|
Loading…
Reference in New Issue