Fiddler Tool for HTTP Debugging

by Sam Allen - Updated January 8, 2010

You want to see how can the Fiddler HTTP debugging tool help you solve caching problems in ASP.NET. For example, enable private caching on your ASP.NET website for performance benefits. Here we use Microsoft's Fiddler tool for debugging, seeing some examples of its output on a website.

Fiddler and HTTP headers

HTTP and Fiddler

For the example, I will examine private caching in ASP.NET. I required a private cache in ASP.NET, meaning one that only the browser would keep. Then I use Fiddler to see what happens. You don't need to change any code to use Fiddler, but here I show the ASP.NET code so we can see what it does. We enable ASP.NET caching and use Fiddler to make sure it works right.

Client-side caching

Here we note that client-side caching is a suggestion. You can use HttpCachePolicy in ASP.NET to indicate to the browsers that they don't need to re-download pages every time. Here we tell browsers to cache pages in their memory. This saves network accesses, and makes everything faster. Use HttpCachePolicy in ASP.NET.

//
// Suggest browsers cache the page.
//
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.Cache.SetExpires(DateTime.Now.AddMinutes(5));

How can I use Fiddler?

Open it alongside Internet Explorer, Google Chrome, or Safari. Fiddler is a HTTP debugging proxy, and we use it to see HTTP connections. It is not only for ASP.NET or IIS. Similar tools are available in Firebug and Safari.

The left side shows connections. These connections are made. The first column shows the Result, which is 200 for HTTP success. Other codes are the famous 404, and 302. It uses special icons. In the left side, blue indicates requests and green indicates downloads. You see when a page wasn't in the client-side cache.

Server-side caching

Servers can also cache HTML on their end, but Fiddler can't distinguish these loads. Server-cached pages will still be sent even if they haven't changed. You should make it so when the user clicks back, your page loads from the browser cache. Visitors click the site icon multiple times. Test this with Fiddler.

GZIP compression

You can use Fiddler to see how much GZIP compression would help your website. Click the radio button on the Transformer tab to count bytes. Additionally, you can read the raw binary in GZIP files using HexView. I used this to see the original file names in my GZIP files. This is useful for low-level server bugs.

Viewing images

Here we mention that you can view images directly in the Fiddler debugging tool, and this can make some debugging responses easier. On the ImageView tab, you can see the images that are sent through HTTP. This is useful for dynamic images, such as those in ASHX handlers.

(See ASHX Handler Tutorial.)

Examine headers

In this section, we note that you can examine the HTTP headers sent from the web server or to the web server by the browser. On the right side of Fiddler (which you can open by double clicking on an item in the left pane), click on Inspectors and then on Headers. These are the raw HTTP headers.

Statistics

Here we note the statistics pane in the Fiddler debugging tool. On the statistics pane, Fiddler offers some estimates about transfer times. I have not found these to be useful. Use web benchmarks instead.

(See HTTP Compression Overview.)

Summary

Here we looked at the Fiddler HTTP debugging proxy tool for the Windows operating system. Caching is complex, but tools like Fiddler or Firebug make it much easier to debug. Using private caching on dynamic pages is important. I explore cache expiration and show code to allow output caching elsewhere on this site.

(Visit www.fiddler2.com.)

(Do not copy this page.)

Dot Net Perls | Search
Tools | Adobe CS3 Rounded Corners Tutorial | ASP.NET Development Server .bat File | FxCop Performance Warnings | Process Explorer and w3wp.exe in ASP.NET | Visual Studio Debugging Tutorial
C# | SaveFileDialog Tutorial | IntegralHeight Property (Windows Forms) | Array.FindIndex Method | File.Replace Method
© 2010 Sam Allen. All rights reserved.
Dot Net Perls | Sam Allen