Preventing Safari background tabs disconnecting from server

power-managementsafarisleep-waketabs

Safari puts background (i.e., currently not selected) tabs to sleep. If that tab is on a website that requires an active connection to its server, such as chat apps (Slack, Google Talk, etc.), then that app will disconnect from the server. Most of them will show you a brief "reconnecting" or "retrying" message when you select that tab again.

Not only this is annoying but it also causes that tab to not update or refresh constantly so I would miss a notification, if there is one, or even lose the session from the server requiring me to type my user credentials again. That happens very often with my company's e-mail web app.

This is not what the App Nap technology does. I've already tried disabling that with

defaults write NSGlobalDomain NSAppSleepDisabled -bool YES  

to no avail.

It isn't the "Stop plug-ins to save power" preference either, as that is disabled and those websites don't use plug-ins.

Does anyone have any tips?

Safari 10.1
macOS Sierra 10.12.4

Best Answer

I think the setting you’re looking for is Disable Hidden Page Timer Throttling, located under DebugMiscellaneous Flags.

If you haven’t enabled the Safari Debug menu yet, triple-click the following line and paste it into a Terminal session:
defaults write com.apple.Safari IncludeInternalDebugMenu 1

Now completely quit Safari, then reopen it. The Debug menu should become available.

If you’re on Safari Technology Preview, the Terminal command is:
defaults write com.apple.SafariTechnologyPreview IncludeInternalDebugMenu 1