Caching static resources returned via VirtualPathProvider

rarfheern

New Member
I'm using a \[code\]VirtualPathProvider\[/code\] that currently maps a virtual path to a directory external to the solution. I'm building this mainly for self-exercise. This is totally equivalent of having a soft-link or NTFS hard-link in the solution's directory.Anyway, I managed to successfully load static images from that virtual directory using my custom provider.Now the problem is that the browser won't cache images. And the server doesn't even think about returning cache information (like ETag).Here is what I've done:
  • \[code\]GetFile(path).Open()\[/code\] returns \[code\]FileStream\[/code\] via \[code\]File.Open()\[/code\]
  • I did not override \[code\]GetCacheKey\[/code\] and \[code\]GetCacheDependencies\[/code\]
  • I did override \[code\]GetFileHash\[/code\] returning the Murmur hash (seems to be the fastest, even than CRC-32) and tested it
  • While debugging, \[code\]GetFileHash\[/code\] is never invoked in my provider
\[code\]CTRL-F5\[/code\]ing only returns the following headers (no reference to cache)\[code\]Cache-Control privateContent-Length 476Content-Type image/pngDate Sat, 29 Dec 2012 21:25:54 GMTServer Microsoft-IIS/8.0X-AspNet-Version 4.0.30319X-Powered-By ASP.NETX-SourceFiles [...]\[/code\]I'm currently debugging in Visual Studio's debug server and Firefox equipped with Firebug.As an example, here is what I expected (http://i.stack.imgur.com/3mn3d.png)\[code\]Accept-Ranges bytesCache-Control max-age=315360000Content-Length 1059Content-Type image/pngDate Sat, 29 Dec 2012 21:35:29 GMTEtag "7d636a8ef932ed081c16ace6f87b16e6"Expires Fri, 12 Feb 2038 09:58:39 GMTLast-Modified Tue, 14 Feb 2012 22:07:18 GMTServer ECAcc (fcn/4089)X-Cache HIT\[/code\]Question is obvious: how can I get the browser not to reload these static resources?
 
Back
Top