SET WIRELESS ADAPTER POWER SAVE OPTION
If you're using WiFi as your primary means of communication with your Pi, you may find that it becomes inaccessible if the wireless adapter has power saving mode set. The adapter will wake up if the Pi wants to communicate out but if it is idle you may not be able to connect to it using SSH or with a browser.
Use this command to determine the current power save setting
/sbin/iw wlan0 get power_save
To change the setting to off use
sudo /sbin/iw wlan0 set power_save off
To avoid power save mode being set to on inadvertently, you can put the command in /etc/rc.local