I never really gave Fiddler all the credit it was due. I guess I should have read the homepage:
Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.
I had previously only used it as a session inspector — to review requests and responses as they occurred in the wild. As it turns out, you can modify request and response headers very easily.
For a quick example, let’s see what it would take to disable connection keep-alive’s when cache-control is set to no-cache. Fire up Fiddler, click Rules, then click “Customize Rules…”. It will pop open CustomRules.js, a JScript file with a Handler class. Scroll down to the OnBeforeResponse static function.
Just after the m_DisableCaching block that is probably already defined, let’s add a simple clause:
if (m_DisableCaching){ oSession.oResponse.headers.Remove("Expires"); oSession.oResponse["Cache-Control"] = "no-cache"; } if (oSession.oResponse["Cache-Control"] == "no-cache") { // Disable keep-alive by setting Connection: close header oSession.oResponse["Connection"] = "close"; }
Fire up IE, visit a page, and look at the Fiddler session logs to see the difference. That easy. Have fun playing with headers!
On a side-note: thank God for Wordpress auto-save. Not that I had much in this article, but I “tabbed” out of the text editor accidentally, hit backspace (forcing the browser to go back), and cursed at the keyboard. Luckily, it was sitting 95% complete in my drafts folder!