title: Using VirtualPathProvider for simple static files
body: <p>We are using custom VirtualPathProvider to serve files from ASP.NET-based web site. To serve static files, like images, css and scripts, we explicitly stated that StaticFileHandler should be used for files with this extension. Like this:</p>
  
  <pre><code>&lt;add verb="GET" path="*.jpg" type="System.Web.StaticFileHandler"&gt;&lt;/add&gt;
  </code></pre>
  
  <p>All of this seems logical and works except one fact - all virtual files served with this handler are coming to client with <strong>"Cache-Control: private"</strong> header. This is not what I would expect for static file. </p>
  
  <p><strong>Is there any good way to make those files cacheable?</strong></p>
  
  <p>Additional info:</p>
  
  <ol>
  <li>Yes, it's possible to add cache header in a simple HttpModule that would add it for all ".js" files, but this is not good way.</li>
  <li>I've found <a href="http://nathanaeljones.com/11081_Using_a_custom_VirtualPathProvider_can_cause_OutOfMemoryExceptions" rel="nofollow noreferrer">this post</a>, that seems related to our problem. It refers to <a href="http://support.microsoft.com/default.aspx/kb/947461#appliesto" rel="nofollow noreferrer">KB947461</a>. But it's not clear, is this patch still not applied to the framework? Almost a year passed. And where to get it, if not.</li>
  </ol>
  
  <p><strong>Update</strong>:
  Looks like patch from <a href="http://support.microsoft.com/default.aspx/kb/947461#appliesto" rel="nofollow noreferrer">KB947461</a> is included in .NET Framework 3.5 SP1. And we already have it installed. </p>
  
  <p><strong>Update 2</strong>: 
  For now we've ended up with this HttpModule that add cache headers if current handler is StaticFileHandler. But this is definitely a crutch.</p>