Issue link: https://read.uberflip.com/i/1146286
Caching Ajax in the Real World | 101 /ws/mail/v1/formrpc?m=GetMessage&yid=steve_souders&msgid=001234 It's possible that the responses are not being cached for data privacy reasons. The Cache-Control: no-store header is commonly used with data that is considered pri- vate. When this header is used, the response is not written to disk at all. However, the HTTP specification warns that you shouldn't rely on this mechanism to ensure data privacy, as malicious or compromised caches may ignore the Cache-Control: no- store header altogether. A better alternative for handling data privacy is using a secure communications pro- tocol such as Secure Sockets Layer (SSL). SSL responses are cacheable (only for the current browser session in Firefox), so it provides a compromise: data privacy is ensured while cached responses improve performance during the current session. Walking through the other relevant performance rules, we can find several positive performance traits in this implementation. The response is gzipped (Rule 4). The domain is used in many other requests in the page, which helps to avoid additional DNS lookups (Rule 9). The XML response is minified as much as possible (Rule 10). It doesn't use redirects (Rule 11). And the ETags are removed (Rule 13). Google Spreadsheets Google Docs & Spreadsheets (http://docs.google.com) offers an Ajax spreadsheet application, which is in beta at the time of this writing. In a typical workflow, the user creates a spreadsheet and saves it in his list of docu- ments. Let's examine what happens when the user returns and opens the spread- sheet. Figure 14-2 shows the HTTP traffic when the spreadsheet is opened—10 active Ajax requests are made. On a side note, this illustrates that Ajax requests are not exclusively XML-fetched using XMLHttpRequest. In Google Spreadsheets, the Ajax requests are HTML and JavaScript. Some of these are requested using XMLHttpRequest, but IFrames are also used. Figure 14-2. Active Ajax requests in Google Spreadsheets redirect html script script html script script html script html script script

