To speed up an AJAX page load, particularly with a toolkit such as dojo, you can do the following:
- Set the cache headers on the server for ‘far-future’ dates on toolkit files, and any other files that don’t change often. Use the directory name and a FilesMatch directive
- Use compression (mod_deflate). If you have a large initial page load, followed by many small AJAX requests, the compression overhead may not be worth it.
- Use dynamic loading to defer the loading of content until it is needed where possible
Use the YSlow plugin for Mozilla Firefox to check for other performance improvements.
Dual Page Population
Often there is some server-side logic that runs the same for the initial page load and later AJAX requests. One approach is to send a flag that indicates whether it is an AJAX request, and to use json_encode followed by an exit() to return the results for AJAX, or Smarty variables to return a full HTML page.