If you lose WIFI after a period of inactivity it is due
to the power-saving-mode of the WiFi-chipset is set to on.
To get rid of this problem, perform the following steps:
* First login to your Pi by ssh.
* verify current setting: by typing:
iw wlan0 get power_save
* This shows, that power-saving is currently on or off.
* If off you are done. If on do the following.
* make the root-partition writable:
sudo mount -o remount,rw /
* edit /etc/network/interfaces:
sudo nano /etc/network/interfaces
* scroll down to the section wlan0 (iface wlan0) after the line
* wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
* insert the following line:
wireless-power off
* Repeat this step for wlan1
* Save the file and reboot!
sudo reboot
* Connect by ssh again, and recheck power-saving:
iw wlan0 get power_save
* Now it should be off. If so you are done.