mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-21 08:45:32 +03:00
Move iconsRoute up
Should intercept first before 'assets'
This commit is contained in:
parent
128a3bacd7
commit
15732dc466
1 changed files with 23 additions and 21 deletions
44
public/sw.js
44
public/sw.js
|
@ -12,6 +12,29 @@ navigationPreload.enable();
|
|||
|
||||
self.__WB_DISABLE_DEV_LOGS = true;
|
||||
|
||||
const iconsRoute = new Route(
|
||||
({ request, sameOrigin }) => {
|
||||
const isIcon = request.url.includes('/icons/');
|
||||
return sameOrigin && isIcon;
|
||||
},
|
||||
new CacheFirst({
|
||||
cacheName: 'icons',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
// Weirdly high maxEntries number, due to some old icons suddenly disappearing and not rendering
|
||||
// NOTE: Temporary fix
|
||||
maxEntries: 300,
|
||||
maxAgeSeconds: 3 * 24 * 60 * 60, // 3 days
|
||||
purgeOnQuotaError: true,
|
||||
}),
|
||||
new CacheableResponsePlugin({
|
||||
statuses: [0, 200],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
);
|
||||
registerRoute(iconsRoute);
|
||||
|
||||
const assetsRoute = new Route(
|
||||
({ request, sameOrigin }) => {
|
||||
const isAsset =
|
||||
|
@ -59,27 +82,6 @@ const imageRoute = new Route(
|
|||
);
|
||||
registerRoute(imageRoute);
|
||||
|
||||
const iconsRoute = new Route(
|
||||
({ request, sameOrigin }) => {
|
||||
const isIcon = request.url.includes('/icons/');
|
||||
return sameOrigin && isIcon;
|
||||
},
|
||||
new CacheFirst({
|
||||
cacheName: 'icons',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
maxEntries: 300,
|
||||
maxAgeSeconds: 3 * 24 * 60 * 60, // 3 days
|
||||
purgeOnQuotaError: true,
|
||||
}),
|
||||
new CacheableResponsePlugin({
|
||||
statuses: [0, 200],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
);
|
||||
registerRoute(iconsRoute);
|
||||
|
||||
// 1-day cache for
|
||||
// - /api/v1/custom_emojis
|
||||
// - /api/v1/lists/:id
|
||||
|
|
Loading…
Reference in a new issue