Better implementation of getHostLocation() with caching

- Checks if there's no port
- Caches the string
- From Minko Gechev - https://gist.github.com/mgechev/6279395