mirror of
https://github.com/maxbarsukov/itmo.git
synced 2026-09-12 19:19:57 +05:00
feat: ✨ prog#9 client update sw
This commit is contained in:
parent
7b56a0f65e
commit
a38527fcfc
@ -46,8 +46,8 @@ registerRoute(
|
||||
);
|
||||
|
||||
setCacheNameDetails({
|
||||
prefix: 'geekr-app',
|
||||
suffix: 'v2',
|
||||
prefix: 'lab9-client',
|
||||
suffix: 'v1',
|
||||
precache: 'precache',
|
||||
runtime: 'runtime',
|
||||
});
|
||||
@ -89,7 +89,6 @@ const newResponse = (
|
||||
|
||||
const cacheHeaderPlugin = [
|
||||
{
|
||||
// @ts-ignore
|
||||
cacheWillUpdate: ({ response }) =>
|
||||
newResponse(response.clone(), (headers: Headers) => {
|
||||
headers.set('x-sw-cache', new Date().getTime().toString());
|
||||
@ -99,28 +98,10 @@ const cacheHeaderPlugin = [
|
||||
];
|
||||
|
||||
registerRoute(
|
||||
/^https?:\/\/.*\/kek\/(v1|v2)\/.*/,
|
||||
/^https?:\/\/.*\/api\/.*/,
|
||||
new NetworkFirst({
|
||||
networkTimeoutSeconds: 10,
|
||||
cacheName: 'api-cache-geekr',
|
||||
plugins: [
|
||||
...cacheHeaderPlugin,
|
||||
new CacheableResponsePlugin({
|
||||
statuses: [200, 201],
|
||||
}),
|
||||
new ExpirationPlugin({
|
||||
maxAgeSeconds: 24 * 60 * 60 * 7, // one week
|
||||
maxEntries: 100,
|
||||
}),
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
registerRoute(
|
||||
/^https?:\/\/habra\.jarvis394\.ml\/.*/,
|
||||
new NetworkFirst({
|
||||
networkTimeoutSeconds: 10,
|
||||
cacheName: 'api-cache-geekr',
|
||||
cacheName: 'api-cache-lab9',
|
||||
plugins: [
|
||||
...cacheHeaderPlugin,
|
||||
new CacheableResponsePlugin({
|
||||
@ -159,7 +140,7 @@ registerRoute(
|
||||
registerRoute(
|
||||
/.*\/fonts\/.*/,
|
||||
new CacheFirst({
|
||||
cacheName: 'geekr-fonts',
|
||||
cacheName: 'lab9-fonts',
|
||||
plugins: [
|
||||
new CacheableResponsePlugin({
|
||||
statuses: [0, 200],
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { NEEDS_UPDATE_KEY } from './config/constants';
|
||||
import { Config } from './serviceWorker';
|
||||
import { NEEDS_UPDATE_KEY } from 'config/constants';
|
||||
import { Config } from 'serviceWorker';
|
||||
|
||||
const config: Config = {
|
||||
onUpdate: (registration: ServiceWorkerRegistration) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user