Issue link: https://read.uberflip.com/i/1146286
Caching Ajax in the Real World | 99 I also agree with his other comment: It's going to be fun. Let's have some fun exploring how to enhance the user experience with Ajax while avoiding the typical pitfalls that can degrade it. Optimizing Ajax Requests The previous section makes it clear that it's possible that the user will be kept wait- ing 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 15 mentions my favor- ite 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 3. 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 10: Minify JavaScript • Rule 11: Avoid Redirects • Rule 13: Configure ETags 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. Caching Ajax in the Real World Let's take a look at some examples to see how Ajax adheres to these performance guidelines in the real world. Yahoo! Mail In our first example, we'll look at the Ajax version of Yahoo! Mail (http://mail.yahoo. com), which is in beta at the time of this writing.

