Browse Source

Fix cache clearing breaking image returns

Former-commit-id: 72b02f8ec749f0e553d8a922a20f011eca66df5c
Former-commit-id: 8b4bc8842829047a47554d22ace90b2482bb2cfe
af/merge-core
James South 12 years ago
parent
commit
da245b53d6
  1. 17
      src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs
  2. 3
      src/TestWebsites/MVC/Views/Web.config

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

@ -348,7 +348,7 @@ namespace ImageProcessor.Web.HttpModules
queryString = this.ReplacePresetsInQueryString(queryString); queryString = this.ReplacePresetsInQueryString(queryString);
// Execute the handler which can change the 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. // If the current service doesn't require a prefix, don't fetch it.
// Let the static file handler take over. // Let the static file handler take over.
@ -456,13 +456,14 @@ namespace ImageProcessor.Web.HttpModules
context.Items[CachedResponseFileDependency] = new List<string> { cachedPath }; 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 // Set the Content-Length header so the client doesn't wait for
// content but keeps the connection open for other requests. // content but keeps the connection open for other requests.
context.Response.AddHeader("Content-Length", "0"); context.Response.AddHeader("Content-Length", "0");
context.Response.StatusCode = (int)HttpStatusCode.NotModified; context.Response.StatusCode = (int)HttpStatusCode.NotModified;
context.Response.SuppressContent = true;
if (isFileLocal) if (isFileLocal)
{ {
@ -560,8 +561,10 @@ namespace ImageProcessor.Web.HttpModules
} }
} }
} }
return queryString; return queryString;
} }
/// <summary> /// <summary>
/// Checks if there is a handler that changes the querystring and executes that handler. /// Checks if there is a handler that changes the querystring and executes that handler.
/// </summary> /// </summary>
@ -574,12 +577,14 @@ namespace ImageProcessor.Web.HttpModules
/// <returns> /// <returns>
/// The <see cref="string"/> containing the updated querystring. /// The <see cref="string"/> containing the updated querystring.
/// </returns> /// </returns>
private string CheckQuerystringHandler(string queryString, string rawUrl) { private string CheckQuerystringHandler(string queryString, string rawUrl)
{
// Fire the process querystring event. // Fire the process querystring event.
ProcessQuerystringEventHandler handler = OnProcessQuerystring; ProcessQuerystringEventHandler handler = OnProcessQuerystring;
if ( handler != null ) { if (handler != null)
{
ProcessQueryStringEventArgs args = new ProcessQueryStringEventArgs { Querystring = queryString ?? string.Empty, RawUrl = rawUrl ?? string.Empty }; ProcessQueryStringEventArgs args = new ProcessQueryStringEventArgs { Querystring = queryString ?? string.Empty, RawUrl = rawUrl ?? string.Empty };
queryString = handler( this, args ); queryString = handler(this, args);
} }
return queryString; return queryString;

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

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

Loading…
Cancel
Save