C# - catch http request and send cached file from shared storage
we want to make a file cache for local in开发者_运维问答ternet provider (like squid). Is it possible in C# to catch request for a file from user and send him local file instead of downloading it from remote server?
Thanks a lot!
Um, it depends upon what you mean by 'catch a request'. You're not talking about squid, are you? If so, problem solved :-).
Otherwise, if you are talking about catching requests that go through a specific web page, you could do it, but it would be pretty hairy. The idea would be to write an http handler that parses a webpage before it is served looking for links. If it finds one and has a local cache, you would re-write the link to point to your copy.
The other (um, better) alternative would be to parse for links when the pages are being created, which would save you a lot of processing power as the pages are being served. each link could be rewritten to pass through a proxy process that caches files and routes based upon its existence.
I told you it was hairy :-)
精彩评论