@Elijah Glover's answer is part of the answer, but is not really complete. This will install the ETag, but you will not get the benefits of ETag without checking it on the server side. You do this with:
var requestedETag = Request.Headers["If-None-Match"]; if (requestedETag == eTagOfContentToBeReturned) return new HttpStatusCodeResult(HttpStatusCode.NotModified);
In addition, another tip is that you need to set the cacheability of the response, otherwise it will be closed by default and ETag will not be set in the response:
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
So a complete example:
public ActionResult Test304(string input) { var requestedETag = Request.Headers["If-None-Match"]; var responseETag = LookupEtagFromInput(input);
jaminto Jul 15 '13 at 16:08 2013-07-15 16:08
source share