Browse Source

A better fix.

Former-commit-id: 94826dd7401ed7f3b07cf397c1079c563dd1e5ca
Former-commit-id: 153a7543f7cd31b1848b6343036c0ecf1780b4e1
af/merge-core
James South 11 years ago
parent
commit
7aa9bfaaa5
  1. 26
      src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs
  2. 3
      src/TestWebsites/MVC/Views/Web.config

26
src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs

@ -453,35 +453,17 @@ namespace ImageProcessor.Web.HttpModules
if (context.Items[CachedResponseFileDependency] == null)
{
context.Items[CachedResponseFileDependency] = new List<string> { cachedPath };
}
string incomingEtag = context.Request.Headers["If-None-Match"];
if (incomingEtag != null && !isNewOrUpdated)
{
// Set the Content-Length header so the client doesn't wait for
// content but keeps the connection open for other requests.
context.Response.AddHeader("Content-Length", "0");
context.Response.StatusCode = (int)HttpStatusCode.NotModified;
if (isFileLocal)
{
// Set the headers and quit.
// Some services might only provide filename so we can't monitor for the browser.
this.SetHeaders(
context,
(string)context.Items[CachedResponseTypeKey],
Path.GetFileName(requestPath) == requestPath ? new List<string> { cachedPath } : new List<string> { requestPath, cachedPath });
context.Items[CachedResponseFileDependency] = Path.GetFileName(requestPath) == requestPath
? new List<string> { cachedPath }
: new List<string> { requestPath, cachedPath };
}
else
{
this.SetHeaders(context, (string)context.Items[CachedResponseTypeKey], new List<string> { cachedPath });
context.Items[CachedResponseFileDependency] = new List<string> { cachedPath };
}
// Complete the requests but don't abort the thread.
context.ApplicationInstance.CompleteRequest();
return;
}
// The cached file is valid so just rewrite the path.

3
src/TestWebsites/MVC/Views/Web.config

@ -49,9 +49,6 @@
</system.web>
<system.webServer>
<staticContent>
<clientCache setEtag="false"/>
</staticContent>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>

Loading…
Cancel
Save