Fiddler – monitor HTTP requests from your browser

Fiddler is invaluable for monitoring HTTP requests from your browser. If you’re investigating HTTP header usage and the effort on caching static content, Fiddler is definitely the way to go, since using the Developer Tools in IE, Chrome or FireBug in Firefox don’t always give you an accurate picture of the actual outgoing HTTP requests. IE is the worst… its developer tool shows HTTP requests going out even though the files are being retrieved from cache. If you really want to see what’s going on then you need something like Fiddler.

To review requests against a server running locally (against localhost), there’s a number of tips in the docs here, but the simplest approach seems to be to use your own IP address (actual address, not 127.0.0.1) instead of localhost or any of the other approaches listed on this page. It works without any other changes.

Extracting cookies using Javascript

Cookies in the current page can be extract using Javascript using ‘document.cookies’ which returns a ‘;’ separated String of all the current cookie values.

You can parse the values with some script like this:

function getCookie(name) {
    var result = '';
    var cookies = document.cookie.split(';');
    for ( var i = 0; i < cookies.length; i++) {
        //alert(cookies[i]);
        var cookie = cookies[i].split('=');
        if (cookie[0].replace(/^s+|s+$/g, '') == name)
            result = cookie[1];
    }
    return result;
}