question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

service-worker: configure response status codes to treat as failed/offline with freshness strategy

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

service-worker

Is this a regression?

No

Description

Expected behaviour: freshness strategy should return to user fetching requested data only if request was successful. If request is unsuccessful (has 500, 504 and other codes) it should return cached result instead of bad result. And bad result should not be cached at all.

But in reality:

freshness strategy return for user bad results.

Interestingly, freshness strategy works as expected if web-server absolutely died (network error: connection refused). I mean, all configured in dataGroup requests begin to return from cache and web-application works despite dead backend. It is different with particular bad request (as I described above).

Performance strategy works as expected (it returns cached results firstly)

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 11.2.19
Node: 14.8.2
OS: darwin x64

Angular: 11.2.14

Anything else?

https://angular.io/guide/service-worker-config#datagroups

https://stackoverflow.com/questions/69132411/angular-service-worker-return-cached-response-if-server-returns-error

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:36
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
anton-marchenkocommented, May 31, 2022

@gkalpak Seems like we have 20+ upvotes.

Could you move the request to your consideration list?

1reaction
gkalpakcommented, May 31, 2022

Interesting 😃 Would anyone be interested in working on a pull request by any chance? 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strategies for service worker caching - Chrome Developers
A caching strategy is an interaction between a service worker's fetch event and the Cache interface. How a caching strategy is written ...
Read more >
503 ok (from serviceWorker) - angular
json to handle dynamic request from the server I get "Status Code:503 OK (from ServiceWorker)" when offline (after first loading). Any thoughts?
Read more >
A guide to Service Workers - pitfalls and best practices
Make sure to set the right scope for your service worker ... object for the given request, which contains the status code of...
Read more >
Keeping things fresh with stale-while-revalidate - web.dev
Let's break down stale-while-revalidate into two parts: the idea that a cached response might be stale, and the process of revalidation. First, ...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
It has been deprecated due to security concerns regarding in-band configuration of a proxy. 306 unused. This response code is no longer used;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found