Improved http response caching

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-07-31 21:48:32 -04:00
parent 98841cb6f8
commit d6a0e8dbc5
2 changed files with 8 additions and 7 deletions

View File

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

View File

@ -54,11 +54,12 @@ namespace MediaBrowser.Common.Net
}
}
Response.SendChunked = true;
Response.StatusCode = statusCode;
if (statusCode != 304)
if (statusCode == 200)
{
Response.SendChunked = true;
if (handler.GzipResponse)
{
Response.AddHeader("Content-Encoding", "gzip");
@ -72,8 +73,8 @@ namespace MediaBrowser.Common.Net
}
else
{
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.SendChunked = false;
Response.OutputStream.Dispose();
}
}
@ -81,7 +82,7 @@ namespace MediaBrowser.Common.Net
{
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.LastModified] = lastModified.ToString("r");
}