fix(sw): network-first + 3s timeout statt SWR fuer Daten
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 30s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 30s
SWR lieferte bei jedem Cache-Hit sofort die alte Antwort und aktualisierte das Cache nur fuer den naechsten Request. Folge: UI zeigte stale Daten, frische Daten erst nach Refresh. Neu: network-first mit 3 s Timeout-Fallback. Netz gewinnt bei frischer Antwort; Timeout oder Netzwerk-Fehler fallen auf Cache zurueck. Pre-Cache-Logik (runSync) bleibt unveraendert, Shell und Bilder bleiben cache-first.
This commit is contained in:
@@ -6,14 +6,16 @@ describe('resolveStrategy', () => {
|
||||
expect(resolveStrategy({ url: '/images/favicon-abc.png', method: 'GET' })).toBe('images');
|
||||
});
|
||||
|
||||
it('swr for recipe HTML pages', () => {
|
||||
expect(resolveStrategy({ url: '/recipes/42', method: 'GET' })).toBe('swr');
|
||||
it('network-first for recipe HTML pages', () => {
|
||||
expect(resolveStrategy({ url: '/recipes/42', method: 'GET' })).toBe('network-first');
|
||||
});
|
||||
|
||||
it('swr for recipe API reads', () => {
|
||||
expect(resolveStrategy({ url: '/api/recipes/42', method: 'GET' })).toBe('swr');
|
||||
expect(resolveStrategy({ url: '/api/recipes/all?sort=name', method: 'GET' })).toBe('swr');
|
||||
expect(resolveStrategy({ url: '/api/wishlist', method: 'GET' })).toBe('swr');
|
||||
it('network-first for recipe API reads', () => {
|
||||
expect(resolveStrategy({ url: '/api/recipes/42', method: 'GET' })).toBe('network-first');
|
||||
expect(resolveStrategy({ url: '/api/recipes/all?sort=name', method: 'GET' })).toBe(
|
||||
'network-first'
|
||||
);
|
||||
expect(resolveStrategy({ url: '/api/wishlist', method: 'GET' })).toBe('network-first');
|
||||
});
|
||||
|
||||
it('network-only for write methods', () => {
|
||||
@@ -34,8 +36,8 @@ describe('resolveStrategy', () => {
|
||||
expect(resolveStrategy({ url: '/manifest.webmanifest', method: 'GET' })).toBe('shell');
|
||||
});
|
||||
|
||||
it('falls through to swr for other same-origin GETs (e.g. root page)', () => {
|
||||
expect(resolveStrategy({ url: '/', method: 'GET' })).toBe('swr');
|
||||
expect(resolveStrategy({ url: '/wishlist', method: 'GET' })).toBe('swr');
|
||||
it('falls through to network-first for other same-origin GETs (e.g. root page)', () => {
|
||||
expect(resolveStrategy({ url: '/', method: 'GET' })).toBe('network-first');
|
||||
expect(resolveStrategy({ url: '/wishlist', method: 'GET' })).toBe('network-first');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user