Skip to content

Commit 785c9b2

Browse files
committed
⚡️(sw) stop to cache external resources likes videos
Some videos from external sources can be very large and slow to cache. To improve performance, we decided to stop caching these resources in the service worker. We will cache only images and fonts from external sources. The videos will maybe not be available when offline mode.
1 parent 3fee1f2 commit 785c9b2

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to
1111
- ✨ Add comments feature to the editor #1330
1212
- ✨(backend) Comments on text editor #1330
1313

14+
### Changed
15+
16+
- ⚡️(sw) stop to cache external resources likes videos #1655
17+
1418
### Fixed
1519

1620
- ♿(frontend) improve accessibility:

src/frontend/apps/impress/src/features/service-worker/service-worker.ts

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -157,33 +157,6 @@ registerRoute(
157157
}),
158158
);
159159

160-
/**
161-
* External urls cache strategy
162-
*/
163-
registerRoute(
164-
({ url }) => !url.href.includes(self.location.origin),
165-
new NetworkFirst({
166-
cacheName: getCacheNameVersion('default-external'),
167-
plugins: [
168-
new CacheableResponsePlugin({ statuses: [0, 200] }),
169-
new ExpirationPlugin({
170-
maxAgeSeconds: 24 * 60 * 60 * DAYS_EXP,
171-
}),
172-
new OfflinePlugin(),
173-
],
174-
}),
175-
'GET',
176-
);
177-
178-
/**
179-
* Admin cache strategy
180-
*/
181-
registerRoute(
182-
({ url }) =>
183-
url.href.includes(self.location.origin) && url.href.includes('/admin/'),
184-
new NetworkOnly(),
185-
);
186-
187160
/**
188161
* Cache strategy static files images (images / svg)
189162
*/
@@ -217,6 +190,24 @@ registerRoute(
217190
}),
218191
);
219192

193+
/**
194+
* External urls cache strategy
195+
*/
196+
registerRoute(
197+
({ url }) => !url.href.includes(self.location.origin),
198+
new NetworkOnly(),
199+
'GET',
200+
);
201+
202+
/**
203+
* Admin cache strategy
204+
*/
205+
registerRoute(
206+
({ url }) =>
207+
url.href.includes(self.location.origin) && url.href.includes('/admin/'),
208+
new NetworkOnly(),
209+
);
210+
220211
/**
221212
* Cache strategy static files (css, js, workers)
222213
*/

0 commit comments

Comments
 (0)