Here's a starting point, this link has some proxy server code.
http://code.cheesydesign.com/?p=393[
^]
Then what you need is an algorithm to change the URL to a filename, which you can store in your cache. So some code like this:
protected static string UrlToFilename(string url) {
string filename = url;
if (filename.Length > 160) {
MD5 hash = MD5.Create();
byte[] hexResult = hash.ComputeHash(Encoding.Unicode.GetBytes(url));
filename = filename.Substring(0, 160) + BitConverter.ToString(hexResult).Replace("-", "");
}
int index;
while ((index = filename.IndexOfAny(System.IO.Path.GetInvalidFileNameChars())) != -1) {
filename = filename.Replace(filename[index], '_');
}
return filename;
}
Then from here you can store the files in a directory structure of your choosing, and in the proxy server, check if the file exists, if so use the file, else fetch from the internet.