The previous section makes it clear that it's possible that the user will be kept waiting when making active Ajax requests. To improve performance, it's important to optimize these requests. The techniques for optimizing active Ajax requests are equally applicable to passive Ajax requests, but since active requests have a greater impact on the user experience, you should start with them.
To find all the active Ajax requests in your web application, start your favorite packet sniffer. (The section "How the Tests Were Done" in Chapter 17 mentions my favorite packet sniffer: IBM Page Detailer.) After your web application has loaded, start using it while watching for Ajax requests that show up in the packet sniffer. These are the active Ajax requests that have to be optimized for better performance.
The most important way to improve these active Ajax requests is to make the responses cacheable, as discussed in Chapter 5. Some of the other 13 rules we've already covered are also applicable to Ajax requests:
Rule 4: Gzip Components
Rule 9: Reduce DNS Lookups
Rule 11: Avoid Redirects
Rule 13: ETags—Use 'Em or Lose 'Em
However, Rule 3 is the most important. It might not be fair for me to create a new rule that simply reapplies previous rules in a new context, but I've found that, because Ajax is so new and different, these performance improvements have to be called out explicitly.