It's been a fun-filled few days but I thought a quick update with the solution is on order. After trying various ways of getting IIS to play nice with Web.config, either in the alternative Media location or in the default Media location, turns out that yes
with a lot of tinkering it *might* be possible but that would be at the cost of the Media Folder module being "plug & play", e.g. we would have to configure virtual directories or a seperate site from which we can serve the media directly.
Core challenge was that the alternative Media path is orchestrated completely within Orchard and therefore IIS still looks for any media files under the default Media folder, including corresponding Web.config files. An added challenge was
that the Media Folder module drops the tenant name, e.g. "Default" from the URL (which is btw a very nice feature!), but the tenant name is still used internally to map to the Media files.
I have created a fork anoordende/clientcache (although changes not yet committed) under the Media Folder project that resolves the issue by re-utilising the clientCache section from the Web.config in the default Media location and by the implementation
of an "IMediaClientCache" which can also be overriden by any other module using a priority.
The default implementation of the IMediaClientCache sets the correct Cache-control, LastModified, etc. and returns a 304 as required if the client includes the If-Modified-Since header. A side-effect of this is that we're no longer depending on
IIS to monitor UNC files for changes, which can be problematic to set up correctly.
A fantastic side effect for me personally is that all my files stored under media are rewritten to a CDN, therefore in combination with the Combinator Module I get .css and .js served from the CDN thrown in for free. Never seen my sites load so fast. Happy
This discussion turned out to be in the wrong place, so I will create a new placeholder under the Media Folder module with a link to here. I will still report back on how I get on with Combinator in my multi server setup.