Cache http hosts and refactor