Wifi Shield stops sending after sometime.

Hi,
When looking for a solution to the same problems in my temp logging setup, i kept finding the presented solutions to the described problems rather complicated.
Starting from the view that simplicity often beats complexity i looked at the most often used code to build some kind of webserver on any arduino-like platform.
It looked to me that a very likely candidate to cause the freezes was the whileclient() statement mostly used to detect the presence of a webclient and to start the delivery of the required html code.
I replaced the while(client.available()) with if(client.available()) and PRESTO since then my Wemos D1 based templogger works as stable as a rock.
It seems that once in awhile the client fails to properly close the connection, causing the server to lock itself into an endless serving loop hence rendering the whole setup locked.
I hope this solution works for you as it worked for me: Like a miracle!