For example, we enable private caching for performance benefits. We use the Fiddler tool for debugging. We see some examples of its output on a website.
Last updated: 10/12/2013
Intro. 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 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 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.
Tip: This saves network accesses, and makes everything faster. Use HttpCachePolicy in ASP.NET.
Fragment that uses SetCacheability: C# // // Suggest browsers cache the page. // Response.Cache.SetCacheability(HttpCacheability.Private); Response.Cache.SetExpires(DateTime.Now.AddMinutes(5));
Usage. To 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 Firefox 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.
Colors: 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 ensure when the user clicks back, your page loads from the browser cache.
Headers: You can examine the HTTP headers sent from the web server or to the web server by the browser.
Tip: On the right side of Fiddler, click on Inspectors and then on Headers. These are the raw HTTP headers.
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. Also, you can read the raw binary in GZIP files using HexView.
Note: I used this to see the original file names in my GZIP files. This is useful for low-level server bugs.
View images. You can view images directly in Fiddler. 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.
Statistics. The statistics pane in the Fiddler debugging tool is available. On the statistics pane, Fiddler offers some estimates about transfer times. I have not found these to be useful. Use web benchmarks instead.
Summary. We looked at the Fiddler HTTP debugging proxy tool for Windows. Caching is complex, but tools like Fiddler or Firebug make it much easier to debug. I explored cache expiration and show code to allow output caching elsewhere on this site.