Tuesday, February 18, 2014

Cache is King in Safari

One trick to speeding up an application is caching. Rather than fetching data from a database or over the network each time you need it, it's better to retrieve the data as soon as possible and hold on to it as long as possible --- and no longer. The only thing worse than slow or no data is bad data.

Autocomplete prefetching over the network before I hit enter.
Last week, I was monitoring a web server log for a URL shortener when I noticed a neat trick Safari does. Rather than waiting for me to hit enter after I typed in a URL, Safari automatically loaded the webpage during the autocomplete phase. It's a brilliantly simple solution. After all, why not start loading a webpage before I ask for it? Actively loading data before it's needed is known as warming up the cache. It's smart since it makes for the best possible user experience (BPUX).

There's nothing like proper optimization, done in small steps, when needed. On the other side of the coin is premature optimization which is the bane of any software engineer's existence. (Rules to Code By)

Another Safari optimization trick I read about but haven't confirmed is that, after loading a web page, Safari will prefetch each link's IP address for faster loading when a user clicks on it since the DNS lookup has already been done.

Anything to speed up my Internet experience is OK by me.

No comments: