-
Notifications
You must be signed in to change notification settings - Fork 828
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
network timeout with networkFirst #1738
Comments
Hey @jamani18 Here's an example of how you should use it: //API cache
workbox.routing.registerRoute(
/.*firebaseio\.com.*\.json$/,
workbox.strategies.networkFirst({
cacheName: "api-cache",
networkTimeoutSeconds: 4,
})
) |
Hi @jadjoubran
As you can see, I have the networkTimeoutSeconds parameter set to 1 second only, but even so, if the response takes more than that time, it is still waiting to pick it up from the network. I leave you a capture of a request simulating a slow type 3g connection with Chrome. You'll see in the capture that the response time is 9 seconds still. Is it a conceptual failure of mine or will it be a bug? Thanks for your time. |
It could be that your regular expression is not matching. If it's the same domain, then please show me your regexp and which url you're trying to match |
The resource I rescue is in the same domain. The regular expression that I used is "/example/" and the resource I request is in the relative address "/example/example.php". The service worker if it detects the element and stores it in cache, rescuing it in case the web is offline. However, if the resource exceeds the response time limit set in networkTimeoutSeconds, it does not rescue it but continues to wait for the response via the network until the response is completed. |
okay, something else to consider: which version of Workbox are you running? |
I'm using version 3.2.0 Edit: I just tried version 3.6.1 and the same thing keeps happening |
okay I'm not sure then sorry :/ |
Thank you anyway. I hope someone knows how to fix it. |
Hey @jamani18 Feel free to use the I also think that this is probably working for you, but you cannot clearly see it in the network tab, you can see it in the From the screenshot you can see how workbox is timing out on the network after 1 second |
Hi @jadjoubran Thank you very much for your response, I managed to find the problem thanks to the code you offered me. The networkTimeoutSeconds works just as you told me. Analyzing my code I found the two reasons that made it not work for me:
Thanks to your example I have managed to discover these problems. When I use new frameworks and I see that the code does not work as expected, one tends to think that it is a problem of the framework without observing that the problem is really not the framework, but rather small errors that my code had. |
Sure thing, I'm glad to hear that it's working now 🎉 |
A huge thanks to @jadjoubran for helping debug this! It's appreciated, Jad! |
Sure thing @jeffposnick! Feel free to mention me for issues that require additional investigation |
(Looking forward to that, @jadjoubran! I'll be at the Perf/PWA Review Clinic area on both days.) |
Good Morning,
I have implemented the API to get my App to work offline, until here everything is correct.
Now I would like to have a maximum load time on the web page, where the client will request a resource via internet, and if this is not received in a maximum of 4 seconds, it will return it via cache.
I have looked at all the tutorials but there is only reference to networkTimeoutSeconds which does not do what I need.
Is there any way to get what I need?
Thank you.
The text was updated successfully, but these errors were encountered: