Skip to content

feat(service-worker): add staleWhileRevalidate strategy #20402

@heddendorp

Description

@heddendorp

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

The service worker only supports networkFirst and cacheFirst caching for DataGroups.

Expected behavior

Also support staleWhileRevalidate Strategy.
As shown here: https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate

What is the motivation / use case for changing the behavior?

This would help with slow data requests, that can not be cached for a long time. They would be way faster while still being al most up to date.
I workaround for now would be to limit the cache time in order to catch repetitive requests, but staleWhileRevalidate is preferable in my opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker packagefeatureLabel used to distinguish feature request from other issuesfreq1: low

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions