Chapter 3. Compression

 

This chapter covers

  • The pros and cons of compression
  • The types of compression available
  • The sample application used in this book
  • How to apply compression to a website

In this chapter we’ll look at the impact compression can have on your site—optimizing front-end performance and taking you closer to your goal of a grade A performance website.

By using compression, you’ll reduce the size of each HTTP request a web page makes, and each reduction will lighten, as it were, the overall weight of the page. By the end of the chapter, you’ll be able to optimize your website with a number of compression techniques in the .NET web technology stack. We’ll go through examples that are applicable to IIS, ASP.NET MVC, and Web Forms.

3.1. What is compression?

Compression is an algorithm that eliminates unwanted redundancy from a file in order to create one that is smaller than the original representation. If both the server and the browser understand this algorithm, it can be applied to the response and request. Web browsers indicate that they support compression in the headers that are sent to the server in the HTTP request. The web server sees this header in the request and will try to compress the response that it sends back.

Compression is extremely easy to implement and is a quick win. You’re about to get up and running using compression, but first it’s important to understand the types of compression.

3.2. Why should I use compression?

3.3. Pros and cons of compression

3.4. Types of compression

3.5. Accept-Encoding

3.6. The Surf Store application

3.7. Adding compression to your website

3.8. The results

3.9. Summary

sitemap