ment. Because the HTML document’s
URL is fixed (bookmarked, linked to,
and so on), it’s necessary to ensure the
response is not cached by the browser.
This is not the case for Ajax responses. The URL of the Ajax request is included inside the HTML document; it’s
not bookmarked or linked to. Developers have the freedom to change the Ajax
request’s URL when they generate the
page. This allows developers to make
Ajax responses cacheable. If an updated
version of the Ajax data is available, the
cached version is avoided by adding a
dynamic variable to the Ajax URL. For
example, an Ajax request for the user’s
address book could include the time
it was last edited as a parameter in the
URL, “&edit=1218050433.” As long as
the user hasn’t edited their address
book, the previously cached Ajax response can continue to be used, making
for a faster page.
Performance analysis with yslow
Evangelizing these performance best
practices is a challenge. I was able to
share this information through confer-
ences, training classes, consulting, and
documentation. Even with the knowledge in hand, it would still take hours
of loading pages in a packet sniffer and
reading HTML to identify the appropriate set of performance improvements. A
better alternative would be to codify this
expertise in a tool that anyone could
run, reducing the learning curve and increasing adoption of these performance
best practices. This was the inspiration
for YSlow.
YSlow ( http://developer.yahoo.com/
yslow/) is a performance analysis tool
that answers the question posed in the
introduction: “Why is this site so slow?”
I created YSlow so that any Web developer could quickly and easily apply the
performance rules to their site, and
find out specifically what needed to be
improved. It runs inside Firefox as an
extension to Firebug (http://getfirebug.
com/), the tool of choice for many Web
developers.
The screenshot in Figure 3 shows
Firefox with iGoogle loaded. Firebug
is open in the lower portion of the window, with tabs for Console, HTML, CSS,
Script, DOM, and Net. When YSlow is installed, the YSlow tab is added. Clicking
YSlow’s Performance button initiates
an analysis of the page against the set of
rules, resulting in a weighted score for
the page.
As shown in Figure 3, YSlow explains
each rule’s results with details about
what to fix. Each rule in the YSlo w screen
is a link to the companion Web site,
where additional information about the
rule is available.
the next Performance
challenge: Javascript
Web 2.0 promises a future where developers can build Web applications
that provide an experience similar to
desktop apps. Web 2.0 apps are built
using JavaScript, which presents significant performance challenges because
JavaScript blocks downloads and rendering in the browser. To build faster
Web 2.0 apps, developers should address these performance issues using
the following guidelines:
˲ Split the initial payload
˲ Load scripts without blocking
˲ Don’t scatter scripts
figure 3: yslow.
split the initial Payload