I happened to click on https://metro.co.uk/ when my wifi went down. Instead of a message from my browser saying no connection, a webpage was loaded saying that the connection was down. If I turn off my wifi and try and load sitepoint I get the usual browser message saying the site couldnt be found.
How is metro.co.uk returning a page when there is no connection? I am assuming there must be some form of cache on my machine for it to do this.
If anyone knows and can either explain how I can do it or point me to a tutorial that would be great as I think this would be a really useful feature for my website.
Well it would kind of depend on where the connection break occurs as to what you were seeing.
For example;
If your site goes down, but youâre behind a system like Cloudflare, then Cloudflare will serve a page to the visitor saying your site is down, but that they managed to reach the Cloudflare service.
If your wifi is down because your ISP has internal problems, the ISP could serve a page to you in a similar sense.
Basically, the last node in the chain that still works can, if they decide to, service the request with an appropriate message, rather than just letting the browser handle it.
Now we come back all the way to the device, and the ability of a cache-failsafe.
I assume, based on the idea of the Metro site, that they are dynamically serving their page on each pageload. However, what may be in your cache could be the loader. That loader could have a âno connectionâ default screen, which gets hidden/replaced once you make a connection to the site source and download the content it wants you to display.
Think of it like a âloadingâ screen - except instead of loading, it says you have no connection. When you pull the page up, it uses Javascript to go send a request out for content. If none comes back, youâre left with the screen that says it couldnt get the content.
It must be the last option as there was no internet connection at all as my wifi had died. Sounds like it might be a bit of a drawback for me if I had to rely on javascript so perhaps not a viable thing for what I want to do.
Iâll have to do a bit of testing and see.
I do not understand how that could happen. If there is no WiFi then how did your browser get a page?
Well, perhaps there was something in the cache. Perhaps the browser got the page from the cache without trying to get it over the internet and then some JavaScript or WebAssembly code tried to do something but could not. If so then you might have gotten a more realistic error if you used F5 or Ctrl-F5 when you got the error.
About twenty years ago I saw a long discussion from a question like this. It is not as easy to define internet is disconnected as you might think.
To clarify I have been to that site previously (not that day but in the past). I donât believe it could return anything otherwise as obviously there is no way for a transfer of information to take place. It must be on my computer already from a previous visit.
My internet connection was completely down. If I tried other websites I go to regularly and the ones I had open at the time they would not load.
It should be easy enough to replicate. Just go to https://metro.co.uk/ and after it loads turn off your wifi and refresh and you should hopefully see the same message I got, instead of a no connection message from the browser.
Why must it be WiFi? Do you expect an Ethernet connection to be different? I have been seeing people say to tap my screen. Well tapping my screen does nothing. Are you assuming that everyone uses smartphones? My guess is that for these forums at least most members use desktop computers with Ethernet connections.
I doubt that I have been to that website before. I unplugged my Ethernet and tried to browse to it and got:
ummâŚare you having a bad day? I was merely trying to clarify and say what I did to create the situation. Would be a bit odd if I said to replicate the problem by doing something different to what Iâd done.
I donât believe I said that it âmustâ be wifi and I didnât mention smartphones at all. What âpeopleâ are telling you to tap your screen? I said nothing at all about tapping anything. Especially since I use wifi on my laptop (youâll find a significant amount of modern laptops donât have an rj45 port so a large amount of people working from home on a laptop likely connect via wifi), although to be fair it does have a touchscreen so technically I could tap it to do things but I donât as itâs weird on a laptop.
I will admit that I didnât also mention ethernet (or mobile broadband either) specifically as an option in my post but seeing how I noticed the issue when my wifi failed I kind of had that in my mind. I guess I did assume people would understand that wifi meant the âinternet connectionâ from my machine. If I just said my âinternet connectionâ failed, as m_hutley pointed out, that has numerous different meanings also.
As for the actual problem the 3rd image is what I was interested in, and as i believe you have shown and as I tried to explain, loads an offline page somehow. Thank you for testing and confirming you could replicate the issue and showing the outcomes. At least hopefully we are now all clear on the original question.
Time a nice cup of tea and a biscuitâŚif you like tea and/or biscuits.
Yes. People that donât think about what they say and say things they do not mean can be frustrating.
You said wifi, not network. WiFi is not wired. I assume you meant either wireless or wired connections. For technical discussions especially, use of the incorrect term can cause problems.
We are getting into off-topic details but my smartphone can connect using Ethernet with the USB port.
I was not sure. There might have been a reason why you said wifi instead of network.
Did you attempt to recreate the problem by deleting the cache?
Whatâs worse is when someone says you said something you didnât, or makes it seem like you said something you didnât!
Itâs pretty simple, if you donât understand something I am saying just ask for clarification. If you donât want to ask, you donât have to reply but please donât say Iâve said things I havenât or bring your random unrelated complaints/frustrations into it as though they have anything to do with me.
I donât really understand why this has taken a turn for the worst but Iâll leave it at that before I say something I regret.
Amazing! People get upset about corrections about words but when the same corrections are made about technical issues it is accepted as normal behavior.
You can do this with a webworker. Itâs a bit of Javascript that loads when someone visits your site and it can then direct where any additional request go. That is, for every HTTP request to your site, the browser will ask the webworker what to do. It can then decide to fetch the actual URL, or return a cached version, etc. Itâs got to complete freedom to do whatever.
So in case you are not connected to the internet the webworker is still asked by the browser what to do and it can server up an offline page. You could also serve a minimal page that still does something. Options are endless.