populate ask whether these performance rules bear on to Web 2.0 applications. They definitely do! This command is the first rule that resulted from working with Web 2.0 applications at Yahoo!.
One of the cited benefits of Ajax is that it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However using Ajax is no guarantee that the user won't be twiddling his thumbs waiting for those asynchronous JavaScript and XML responses to return. In many applications whether or not the user is kept waiting depends on how Ajax is used. For example in a web-based telecommunicate client the user will be kept waiting for the results of an Ajax request to find all the telecommunicate messages that match their search criteria. It's important to bequeath that "asynchronous" does not imply "instantaneous".
To improve performance it's important to optimize these Ajax responses. The most important way to alter the performance of Ajax is to alter the responses cacheable as discussed in. Some of the other rules also apply to Ajax:
However. Rule 3 is the most important for speeding up the user experience. Let's look at an example. A Web 2.0 email client might use Ajax to transfer the user's address book for autocompletion. If the user hasn't modified her address schedule since the last time she used the email web app the previous address book response could be read from cache if that Ajax response was made cacheable with a future Expires header. The browser must be informed when to use a previously cached address book response versus requesting a new one. This could be done by adding a timestamp to the address schedule Ajax URL indicating the last time the user modified her address schedule for example.
If the address book hasn't been modified since the measure transfer the timestamp will be the same and the address book ordain be construe from the browser's cache eliminating an extra HTTP roundtrip. If the user has modified her address schedule the timestamp ensures the new URL doesn't be the cached response and the browser will request the updated address book entries.
Even though your Ajax responses are created dynamically and might only be applicable to a single user they can still be cached. Doing so ordain make your Web 2.0 apps faster.
"This could be done by adding a timestamp to the address book Ajax URL indicating the last time the user modified her address book for example. &t=1190241612"
Does that work across all browsers? I was under the impression that IE would never cache a HTTPXMLRequest response that has a parameter in it's URL. I haven't tested it though..
Also. Wikipedia indicates that IE and Firefox use caching header differently (http://en wikipedia org/wiki/XMLHttpRequest#Caching). Is this the case?
If you _do_ be the XHR to be cached you can comfort include a querystring but the parameters must be the same as seen in this example:
In that example the XHR URL has a querystring and yet it is still read from cache in both Firefox and IE. In order for the XHR to be cached you have to do more than simply act the URL constant. You also have to give a future Expires or Cache-Control header as explained in Rule 3.
It's likely that the person who wrote the Wikipedia bind did not provide the necessary headers for the XHR to be cached. Or perhaps it was an older version of Firefox (I'm on Firefox 2.0 but am sure Firefox 1.5 behaves the same). Finally it's possile they had changed their browser cache settings or were running a utility like Fasterfox that altered the typical behavior of Firefox. Bottomline: Firefox does lay aside XHR responses if the URL is the same and the headers set the expiration date in the future.
Data privacy is critical whenever thinking about caching. Each application must end how to handle privacy issues. In my opinion confidential information should be transmitted using SSL. I'll point out that the Web 2.0 versions of Google Mail and Yahoo! send do not undergo a single https request. The ideal situation in my mind would be to transmit over SSL and give the user the option about caching. Since I'm the only user on my PC. I would opt-in for caching. Fortunately caching of https responses is supported in IE.
thanks for your rules,they help me much:)But there is a problem,for a mail user,his client,ie,etc need to affix request to server timely so it can know whether there is a new mail coming. How to reduce these kind of request?Or whether there is someway that server can push some data to the client without using long-connecting?thx:)
We here at Siderean have been devotees of YUI since its inception. Most of the library has proven its worth. However regarding cacheable XHR objects we've tried your web page on IE6. IE7 as come up as FF2.0.0.11. We've also tested on Mac OS X running FF 2.0.0.11. All tests of the web summon seemed to have failed - i e the dialogue "The XMLHttpRequest was sent" appears. Has something changed in the caching mechanism ?
Hi. Riley. Don't use the dialog box as an indicator of HTTP merchandise. Instead use a packet sniffer as suggested in the instructions. The dialog box is just telling you that an XHR was executed. change surface though the XHR is executed on subsequent requests it's read from cache which is the inform of that demo page. To make it clearer I changed the communicate to say "The XMLHttpRequest was executed but it MIGHT have been read from the browser's lay aside. Use a packet sniffer to see." When I run the demo (http://stevesouders com/hpws/xhr-cached php) on Firefox and IE with a packet sniffer I see that the second XHR is in fact construe from lay aside.
Forex Groups - Tips on Trading
Related article:
http://developer.yahoo.net/blog/archives/2007/09/high_performanc_12.html
comments | Add comment | Report as Spam
|