It's surprisingly easy actually - I'm really impressed with Fiddler!!
static function OnBeforeRequest(oSession: Session)
{
// Cache Onyx Scripts and Static Resources
if (oSession.host.match(/
crm.lgs-net.com/) &&
oSession.HTTPMethodIs("GET") &&
oSession.url.match(/\.(js$)|(gif$)|(jpe?g$)|(css$)/))
{
var s:String = oSession.host + oSession.PathAndQuery;
s = s.Replace("/", "\\");
s = s.Replace(":", "+");
s = "C:\\temp\\" + s;
if (System.IO.File.Exists(s)) {
oSession["x-replywithfile"] = s;
oSession["ui-comments"] = "hit";
} else {
oSession.SaveResponseBody(s);
oSession["ui-comments"] = "miss";
}
}
}
I just have one small issue to solve. Very occasionally Fiddler seems
to save a file of 0 bytes which is unusable. I need to therefore check
more than just if the file exists but verify its size. When I do this,
Fiddler cannot parse the script though it appears to me to be
valid .NET code:
MessageBox.Show(System.IO.FileInfo("C:\temp\test.htm").Length);
I've also tried:
var l:long = System.IO.FileInfo("C:\temp\test.htm").Length;
Same error: Type mismatch