Sunday, October 21, 2012

Ultra fast ASP.NET

1. A good rule of thumb is to load your static content from two or three domains. You might want to have several domain aliases for your site. That allows you to optimize download parallelism by simply adjusting the domain names in your pages, without having to manage which content is in which domain. Consider automating the process of assigning static files to particular domains using an ASP.NET control adapter just be sure to use a consistent domain for each resource, to avoid unwanted cache misses.

2. To reduce round-trips, you should have as few script files as possible. You can arrange this by doing one or more of the following:
  • Combine them together statically (such as with an editor)
  • Combine them together dynamically, either:
    • As a compile post-processing step or
    • Programmatically (on-demand) when the browser requests the script. The .NET Framework supports automated bundling.
3. Mid-document script includes can cause the browser to delay rendering the page until after the script file arrives. From a performance perspective, it’s better to place your includes at the end of your HTML when you can. A common reason for using mid-document script includes is to insert HTML into the page using document.write().
  • Instead of document.write(), use innerHTML or direct DOM manipulation, which you can do late in the HTML
  • If you can’t avoid document.write() (such as with scripts from third-parties), then instead of using multiple

No comments: