timing is everything

I discovered something strange and bothersome today when I began a debugging session on a Node.js—based website I was working on.  My logs were clearly showing that my browser was pre-caching content from a site before I visited it.

PrematureSafari_640x400

As you can see from the console.log() content on the right and a new Safari session, the browser is already fetching content in realtime as I type in “http:” in the address field.  Note that I haven’t pressed Enter or clicked anything yet to initiate the download.  Also note that the indicated site that’s been matched in the URL isn’t the site I’m debugging.  The site whose log is on the right is served on a different port.  So the assumption here is that Safari on startup tries to make things seem faster by pre-caching content from what it thinks you’ll need later.

“…Safari on startup tries to make things seem faster by pre-caching content from what it thinks you’ll need later.”

I already had a sense of this on my iOS device since it’s painfully slow when you switch back to the Safari app and hope to quickly lookup something.  No joy.  The iOS Safari app seemingly takes forever because of this startup pre-caching phase, it really grinds its gears trying to reload content from all the tabs that were open before, creating an unresponsive experience for the user.

What does this mean to the software developer?  Normally, we expect to follow a link and then the browser does our bidding. We next expect to review the logs in realtime and watch the performance for a session.  In some workflows I might startup the browser, edit a page, save that page and then visit the link to review the work I’ve just done.  But here we see that the browser anticipated that I might re-visit the site and has begun caching the content in case I might then ask for it.  For this scenario it was my intention though to see what it looks like including my latest edits and that’s not necessarily what I’d be viewing—I could very well be seeing the site from before my edits because my browser was trying to provide a responsive experience for me.

Looking for a workaround within Safari’s preferences, there doesn’t immediately seem to be a feature to turn off pre-caching of content.  This thread however appears to be addressing the concern and the following preference setting may be toggled off.

SafariPreferences_640x225

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s