About WebWait and Caching

I received today a question often asked about WebWait, so I’ll answer it here for reference.

WebWait User asks:

I have been using webwait for a while and have a quick question for you. When running multiple calls on the same website, is each call downloading the entire page again, or is the information being loaded from the browser cache?

My answer:

It will do whatever the browser would do if the page was loaded normally, so that would usually mean the 2nd-Nth time it will download from the cache. To counter-act that, you can simply disable your browser cache while performing your tests. Or if you do want to test cache performance, just open your site once (either in the browser or WebWait) and then start the WebWait tests, obviously keeping the cache enabled throughout.

Ajax as a Remedy for the Cacheability-Personalization Dilemma

A pattern for your consideration, about using Ajax to help pages be RESTful.

Problem

How to personalize content and make pages cacheable and bookmarkable at the same time?

Forces

  • We want pages to have clean URLs that describe the main content being viewed. Doing so makes pages easily bookmarkable and send-to-friend-able, and also allows us to cache the page anywhere along the way. For example, viewing info about Fight Club should be http://example.com/fightclub and not http://example.com/fightclub/user-mahemoff or http://example.com/fightclub/287490270-1931321-cijE12ZSz
  • .
  • We want to personalize pages – say Hi to the user, show them personalized recommendations, etc.
  • If we personalize, but use the same URL for all users, we break REST and therefore won’t be able to cache any content. My http://example.com/fightclub is different to your http://example.com/fightclub because we each see our own recommendations inside the page.
  • But if we use diferent URLs for personalization, we can’t cache across users and pages aren’t sent-to-friend-able. If I look up and see http://example.com/fightclub/user-mahemoff, I’m probably not going to bother sending you the URL. Furthermore, my view of the page can’t be cached.

Solution

Create pages generically (same version for all users), and in this generic version, embed a remoting call which will customize the page for the current user. Serve http://example.com/fightclub to everyone. Then everyone’s browser makes a further call to grab custom content (Multi-Stage Download). This additional call is unRESTful as the server will use cookies to decide what content to return, but at least we’ve isolated that component, served the bulk of the content without caching, and given the user something they can bookmark and send to their friends.

References