Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new "cachedResponseIsAbsent" method for custom plugins #3298

Open
johnrobertcobbold opened this issue Feb 25, 2024 · 0 comments
Open

new "cachedResponseIsAbsent" method for custom plugins #3298

johnrobertcobbold opened this issue Feb 25, 2024 · 0 comments

Comments

@johnrobertcobbold
Copy link

Feature Request Description:

I would like to request for a new method for custom plugins called "cachedResponseIsAbsent" for example.

What is the use case? To be informed if no cached response was found and the request will have to solely depend on a fetch. Indeed, when requestWillFetch is fired within a StaleWhileRevalidate strategy plugin, we still do not know if a cached response will be found. Our service worker is using client.postMessage() to inform the client of these different events so as to fine-tune the UX. The only solution for now seems to set a timeOut after receiving a message from requestWillFetch to see if cachedResponseWillBeUsed will also fire just after. Instead, it would be easier to have a "cachedResponseIsAbsent" message the client.

In our specific case:
If cachedResponseWillBeUsed fires after requestWillFetch fires, we show the cached content + an "updating" message
If cachedResponseIsAbsent fires instead after requestWillFetch fires, there is no cached content to display so we instead show some placeholders without any updating message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant