**Summary** __Fast ASP.NET Websites__ delivers just what it promises—practical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. **About the Technology** There's a real cost to inefficient HTTP requests, overloaded data streams and bulky scripts. Server throughput is a precious commodity and seconds—even tiny fractions of a second—can seem like an eternity while a visitor waits for your site to load. As an ASP.NET developer, there are dozens of techniques you can apply immediately to make your sites and applications faster. You'll find them here. **About this Book** __Fast ASP.NET Websites__ delivers just what it promises—practical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. Readers should be familiar with basic HTML, CSS, and ASP.NET concepts. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. **What's Inside** * Drastically improved response times * Tips for Webforms and ASP.NET MVC sites * Optimizing existing pages * .NET-specific examples **About the Author** **Dean Hume** is a software developer and blogger based in the U.K. A passionate techie, he created the ASP.NET HTML5 toolkit and blogs regularly about web performance at www.deanhume.com. **Table of Contents** PART 1 DEFINING PERFORMANCE 2. High-speed websites 3. First steps toward a faster website PART 2 GENERAL PERFORMANCE BEST PRACTICES 5. Compression 6. Caching: The sell-by date 7. Minifying and bundling static files 8. HTML optimization tips 9. Image optimization 10. ETags 11. Content Delivery Networks PART 3 ASP.NET-SPECIFIC TECHNIQUES 13. Tweaking ASP.NET MVC performance 14. Tweaking ASP.NET Web Forms performance 15. Data caching Front cover 1 contents 6 preface 12 acknowledgments 13 about this book 15 How to use this book 15 Who should read this book 15 Roadmap 16 Code conventions and downloads 17 Software requirements 17 Author Online 18 About the cover illustration 18 Part 1—Defining performance 20 1 High-speed websites 22 1.1 Why optimize? 23 1.2 The financial impact 23 1.2.1 The business impact 24 1.2.2 The search engine ranking impact 24 1.2.3 The mobile user impact 25 1.2.4 The environmental impact 25 1.3 How to optimize 25 1.3.1 Profile 26 1.3.2 Identify 26 1.3.3 Implement 26 1.3.4 Monitor 27 1.4 Where to optimize 27 1.5 The Performance Golden Rule 28 1.6 Summary 28 2 First steps toward a faster website 30 2.1 The basics of HTTP 30 2.1.1 Understanding an HTTP GET request 31 2.1.2 Understanding an HTTP GET response 32 2.1.3 Understanding HTTP status codes 34 2.2 Empty cache vs. primed cache 35 2.3 Tips and tools for interpreting performance charts 36 2.3.1 What does it all mean? 36 2.3.2 Google Chrome developer tools 38 2.3.3 Internet Explorer developer tools 40 2.3.4 Firebug 40 2.3.5 Safari Web Inspector 40 2.3.6 HTTPWatch 41 2.3.7 WebPagetest 41 2.3.8 Fiddler 41 2.4 Performance rules to live by 42 2.4.1 Yahoo! YSlow 43 2.4.2 Google PageSpeed 44 2.5 Summary 45 Part 2—General performance best practices 46 3 Compression 48 3.1 What is compression? 48 3.2 Why should I use compression? 49 3.3 Pros and cons of compression 51 3.4 Types of compression 51 3.4.1 Gzip 51 3.4.2 Deflate 52 3.4.3 SDCH 52 3.5 Accept-Encoding 52 3.6 The Surf Store application 53 3.7 Adding compression to your website 54 3.7.1 Using IIS to add compression to a website 55 3.7.2 Using a Web.config file to add compression to a website 57 3.7.3 Adding compression with other techniques 59 3.8 The results 59 3.9 Summary 61 4 Caching: The sell-by date 62 4.1 What is HTTP caching? 63 4.2 IIS and HTTP caching 65 4.3 Web.config settings 69 4.4 Caching considerations 69 4.5 Output caching 70 4.5.1 Output caching in an ASP.NET MVC application 70 4.5.2 Output caching in an ASP .NET Web Forms application 73 4.6 The results of HTTP caching 75 4.7 Summary 76 5 Minifying and bundling static files 78 5.1 What is minification? 78 5.2 What is bundling? 82 5.3 New bundling and minifying features in ASP.NET 4.5 82 5.4 Utilizing bundling in ASP.NET MVC 85 5.5 Utilizing bundling in ASP.NET Web Forms 88 5.6 The results 91 5.7 Summary 93 6 HTML optimization tips 94 6.1 Where to position CSS and JavaScript in a web page to achieve the best performance 95 6.1.1 CSS 95 6.1.2 JavaScript 97 6.2 How the order of styles and scripts affects rendering 98 6.2.1 The impact of duplicate scripts 100 6.3 HTML5 100 6.4 A note on HTML5 browser support 101 6.4.1 HTML5 asynchronous JavaScript 102 6.4.2 HTML5 Web Workers 104 6.4.3 Browser support for HTML5 Web Workers 105 6.4.4 HTML5 Web Workers in an ASP.NET MVC application 106 6.4.5 Web Workers in an ASP.NET Web Forms application 108 6.5 HTML5 application cache 110 6.5.1 HTML5 application cache considerations 111 6.5.2 HTML5 application cache in an ASP.NET MVC application 112 6.5.3 HTML5 application cache in an ASP.NET Web Forms application 115 6.5.4 Application cache support 116 6.6 Summary 117 7 Image optimization 118 7.1 What’s the big deal with image optimization? 119 7.2 Online image optimization tools 119 7.2.1 Smush.it 120 7.2.2 Kraken 120 7.3 Command line image optimization tools 121 7.3.1 Pngcrush 122 7.3.2 Jpegtran 122 7.4 Image Optimizer—a Visual Studio extension 122 7.5 Using data URIs 123 7.5.1 Implementing data URIs in an ASP.NET MVC application 125 7.5.2 Implementing data URIs in an ASP.NET Web Forms application 128 7.6 The importance of specifying image dimensions 132 7.7 The results 133 7.8 Summary 134 8 ETags 136 8.1 What are ETags? 137 8.2 Why should I change ETags? 139 8.3 Removing ETags in ASP.NET Web Forms and ASP.NET MVC applications 140 8.4 The results 141 8.5 Summary 142 9 Content Delivery Networks 144 9.1 What is a Content Delivery Network? 145 9.2 CDN options 147 9.3 Domain sharding 147 9.4 Developing with a CDN 149 9.4.1 ASP.NET MVC HTML helper for CDN development 149 9.4.2 ASP.NET Web Forms helper for CDN development 151 9.5 The results 153 9.6 Summary 155 Part 3—ASP.NET– specific techniques 156 10 Tweaking ASP.NET MVC performance 158 10.1 Using only the view engines that you need 159 10.2 Release mode vs. Debug mode 160 10.3 The importance of a favicon 162 10.4 Utilizing a code profiler 165 10.4.1 MiniProfiler for database profiling 171 10.5 Summary 173 11 Tweaking ASP.NET Web Forms performance 174 11.1 HTML improvements 175 11.2 Web.config settings 177 11.2.1 Publishing your application in Release mode 177 11.2.2 Disable tracing if it’s not used 178 11.2.3 Disable session state 179 11.2.4 Disable ViewState when it’s not needed 179 11.3 Response.Redirect vs. Server.Transfer 180 11.4 Utilizing a code profiler 181 11.5 Fixing the issue 187 11.6 Summary 188 12 Data caching 190 12.1 Server-side data caching 191 12.2 System.Runtime.Caching 191 12.3 What should I cache? 194 12.4 The sample application 194 12.5 Notes on distributed caching 196 12.6 Summary 197 12.7 Look at how far you’ve come! 197 appendix 200 A.1 Setting up your local machine as a web development server with IIS 200 A.2 Useful links referenced in this book 202 index 204 Numerics 204 A 204 B 204 C 204 D 205 E 205 F 205 G 206 H 206 I 206 J 207 K 207 L 207 M 207 N 207 O 207 P 208 R 208 S 208 T 209 U 209 V 209 W 209 X 209 Y 209 Z 209 Back cover 210 Annotation SummaryFast ASP.NET Websites delivers just what it promisespractical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. About the TechnologyThere's a real cost to inefficient HTTP requests, overloaded data streams and bulky scripts. Server throughput is a precious commodity and secondseven tiny fractions of a secondcan seem like an eternity while a visitor waits for your site to load. As an ASP.NET developer, there are dozens of techniques you can apply immediately to make your sites and applications faster. You'll find them here. About this BookFast ASP.NET Websites delivers just what it promisespractical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. Readers should be familiar with basic HTML, CSS, and ASP.NET concepts. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. What's InsideDrastically improved response timesTips for Webforms and ASP.NET MVC sitesOptimizing existing pages.NET-specific examplesAbout the AuthorDean Hume is a software developer and blogger based in the U.K.A passionate techie, he created the ASP.NET HTML5 toolkit and blogs regularly about web performance at www.deanhume.com. Table of ContentsPART 1 DEFINING PERFORMANCEHigh-speed websitesFirst steps toward a faster websitePART 2 GENERAL PERFORMANCE BEST PRACTICESCompressionCaching: The sell-by dateMinifying and bundling static filesHTML optimization tipsImage optimizationETagsContent Delivery NetworksPART 3 ASP.NET-SPECIFIC TECHNIQUESTweaking ASP.NET MVC performanceTweaking ASP.NET Web Forms performanceData caching Summary Fast ASP.NET Websites delivers just what it promisespractical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. About the Technology There's a real cost to inefficient HTTP requests, overloaded data streams and bulky scripts. Server throughput is a precious commodity and secondseven tiny fractions of a secondcan seem like an eternity while a visitor waits for your site to load. As an ASP.NET developer, there are dozens of techniques you can apply immediately to make your sites and applications faster. You'll find them here. About this Book Fast ASP.NET Websites delivers just what it promisespractical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. Readers should be familiar with basic HTML, CSS, and ASP.NET concepts. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. What's Inside About the Author Dean Hume is a software developer and blogger based in the U.K. A passionate techie, he created the ASP.NET HTML5 toolkit and blogs regularly about web performance at (http://www.deanhume.com) www.deanhume.com . Table of Contents Fast ASP.NET Websites delivers just what it promises{u2014}practical, hands-on guidance to create faster, more efficient ASP.NET sites and applications. This book offers step-by-step .NET-specific examples showing you how to apply classic page optimization tips, ASP.NET-specific techniques, and ways to leverage new HTML5 features. Readers should be familiar with basic HTML, CSS, and ASP.NET concepts. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications