Browse Source

Fix cache clearing breaking image returns

Former-commit-id: 72b02f8ec749f0e553d8a922a20f011eca66df5c
Former-commit-id: 8b4bc8842829047a47554d22ace90b2482bb2cfe
pull/17/head
James South 11 years ago
parent
commit
2c36fbfeed
  1. 19
      src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs
  2. 5
      src/TestWebsites/MVC/Views/Web.config

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

@ -346,9 +346,9 @@ namespace ImageProcessor.Web.HttpModules
// Replace any presets in the querystring with the actual value.
queryString = this.ReplacePresetsInQueryString(queryString);
// Execute the handler which can change the querystring
queryString = this.CheckQuerystringHandler( queryString, request.RawUrl );
queryString = this.CheckQuerystringHandler(queryString, request.RawUrl);
// If the current service doesn't require a prefix, don't fetch it.
// Let the static file handler take over.
@ -456,13 +456,14 @@ namespace ImageProcessor.Web.HttpModules
context.Items[CachedResponseFileDependency] = new List<string> { cachedPath };
}
if (!isNewOrUpdated)
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;
context.Response.SuppressContent = true;
if (isFileLocal)
{
@ -560,8 +561,10 @@ namespace ImageProcessor.Web.HttpModules
}
}
}
return queryString;
}
/// <summary>
/// Checks if there is a handler that changes the querystring and executes that handler.
/// </summary>
@ -574,12 +577,14 @@ namespace ImageProcessor.Web.HttpModules
/// <returns>
/// The <see cref="string"/> containing the updated querystring.
/// </returns>
private string CheckQuerystringHandler(string queryString, string rawUrl) {
private string CheckQuerystringHandler(string queryString, string rawUrl)
{
// Fire the process querystring event.
ProcessQuerystringEventHandler handler = OnProcessQuerystring;
if ( handler != null ) {
if (handler != null)
{
ProcessQueryStringEventArgs args = new ProcessQueryStringEventArgs { Querystring = queryString ?? string.Empty, RawUrl = rawUrl ?? string.Empty };
queryString = handler( this, args );
queryString = handler(this, args);
}
return queryString;

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

@ -45,10 +45,13 @@
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<staticContent>
<clientCache setEtag="false"/>
</staticContent>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>

Loading…
Cancel
Save