Improved http response caching

pull/702/head
LukePulverenti Luke Pulverenti luke pulverenti 12 years ago
parent 98841cb6f8
commit d6a0e8dbc5

@ -86,7 +86,7 @@ namespace MediaBrowser.Common.Net.Handlers
WriteStream = s => WriteStream = s =>
{ {
WriteReponse(s); WriteReponse(s);
s.Close(); s.Dispose();
}; };
} }

@ -54,11 +54,12 @@ namespace MediaBrowser.Common.Net
} }
} }
Response.SendChunked = true;
Response.StatusCode = statusCode; Response.StatusCode = statusCode;
if (statusCode != 304) if (statusCode == 200)
{ {
Response.SendChunked = true;
if (handler.GzipResponse) if (handler.GzipResponse)
{ {
Response.AddHeader("Content-Encoding", "gzip"); Response.AddHeader("Content-Encoding", "gzip");
@ -72,8 +73,8 @@ namespace MediaBrowser.Common.Net
} }
else else
{ {
Response.OutputStream.Flush(); Response.SendChunked = false;
Response.OutputStream.Close(); Response.OutputStream.Dispose();
} }
} }
@ -81,7 +82,7 @@ namespace MediaBrowser.Common.Net
{ {
DateTime lastModified = dateModified ?? DateTime.Now; DateTime lastModified = dateModified ?? DateTime.Now;
response.Headers[HttpResponseHeader.CacheControl] = "Public"; response.Headers[HttpResponseHeader.CacheControl] = "public, max-age=" + Convert.ToInt32(duration.TotalSeconds);
response.Headers[HttpResponseHeader.Expires] = DateTime.Now.Add(duration).ToString("r"); response.Headers[HttpResponseHeader.Expires] = DateTime.Now.Add(duration).ToString("r");
response.Headers[HttpResponseHeader.LastModified] = lastModified.ToString("r"); response.Headers[HttpResponseHeader.LastModified] = lastModified.ToString("r");
} }

Loading…
Cancel
Save