cache: scope all keys we use
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/672/head
parent
6b2e462496
commit
0c5e1cb5b0
|
@ -20,7 +20,7 @@ let fetchPreviewQueue: FetchPreviewObject[] = [];
|
|||
const pendingUrls = new Map<string, BlobCallback[]>();
|
||||
|
||||
// Cache for preview images
|
||||
const cacheName = 'images';
|
||||
const cacheName = 'memories-images';
|
||||
let imageCache: Cache;
|
||||
(async function openCache() {
|
||||
try {
|
||||
|
|
|
@ -9,7 +9,7 @@ cleanupOutdatedCaches();
|
|||
registerRoute(
|
||||
/^.*\/apps\/memories\/api\/video\/livephoto\/.*/,
|
||||
new CacheFirst({
|
||||
cacheName: 'livephotos',
|
||||
cacheName: 'memories-livephotos',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
maxAgeSeconds: 3600 * 24 * 7, // days
|
||||
|
@ -30,7 +30,7 @@ const networkOnly = [/^.*\/api\/.*/];
|
|||
registerRoute(
|
||||
({ url }) => url.origin === self.location.origin && url.pathname.endsWith('/apps/memories/'),
|
||||
new NetworkFirst({
|
||||
cacheName: 'pages',
|
||||
cacheName: 'memories-pages',
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -38,7 +38,7 @@ registerRoute(
|
|||
registerRoute(
|
||||
({ url }) => url.origin === self.location.origin && !networkOnly.some((regex) => regex.test(url.href)),
|
||||
new CacheFirst({
|
||||
cacheName: 'pages',
|
||||
cacheName: 'memories-pages',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
maxAgeSeconds: 3600 * 24 * 7, // days
|
||||
|
|
|
@ -44,7 +44,7 @@ class StaticConfig {
|
|||
}
|
||||
|
||||
// Clear page cache, keep other caches
|
||||
window.caches?.delete('pages');
|
||||
window.caches?.delete('memories-pages');
|
||||
}
|
||||
|
||||
// Assign to existing default
|
||||
|
|
|
@ -6,7 +6,7 @@ const uid = getCurrentUser()?.uid || 'guest';
|
|||
|
||||
async function getCacheName() {
|
||||
const ver = await config.get('version');
|
||||
return `memories-${ver}-${uid}`;
|
||||
return `memories-data-${ver}-${uid}`;
|
||||
}
|
||||
|
||||
// Clear all caches except the current one
|
||||
|
@ -19,7 +19,7 @@ async function getCacheName() {
|
|||
const cacheName = await getCacheName();
|
||||
|
||||
for (const key of keys) {
|
||||
if (key.startsWith('memories-') && key !== cacheName) {
|
||||
if (key.match(/^memories-data-/) && key !== cacheName) {
|
||||
window.caches.delete(key);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue