I'm using a VirtualPathProvider
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:
GetFile(path).Open()
returnsFileStream
viaFile.Open()
- I did not override
GetCacheKey
andGetCacheDependencies
- I did override
GetFileHash
returning the Murmur hash (seems to be the fastest, even than CRC-32) and tested it - While debugging,
GetFileHash
is never invoked in my provider
CTRL-F5
ing only returns the following headers (no reference to cache)
Cache-Control private
Content-Length 476
Content-Type image/png
Date Sat, 29 Dec 2012 21:25:54 GMT
Server Microsoft-IIS/8.0
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
X-SourceFiles [...]
I'm currently debugging in Visual Studio's debug server and Firefox equipped with Firebug.
As an example, here is what I expected (https://i.stack.imgur.com/3mn3d.png)
Accept-Ranges bytes
Cache-Control max-age=315360000
Content-Length 1059
Content-Type image/png
Date Sat, 29 Dec 2012 21:35:29 GMT
Etag "7d636a8ef932ed081c16ace6f87b16e6"
Expires Fri, 12 Feb 2038 09:58:39 GMT
Last-Modified Tue, 14 Feb 2012 22:07:18 GMT
Server ECAcc (fcn/4089)
X-Cache HIT
Question is obvious: how can I get the browser not to reload these static resources?