I am attempting to manage all image GETs in a web site. To do this I am using
an IHttpHandler. All the basic functionality works well.
I am attempting to manage the caching of images on the client site using the
following snippet of code. The code attempts to set both "If-Modified-Since"
and "ETag" headers which will be used to determine whether the image needs to
be updated or not on any subsequent GET.
context.Response.Clear();
context.Response.ContentType = getContentType(context.Request.PhysicalPath);
context.Response.Cache.SetCacheability(HttpCacheab ility.Private)
context.Response.Cache.SetLastModified(getFileModi fiedDate(context.Request.PhysicalPath));
context.Response.Cache.VaryByHeaders["If-Modified-Since"] = true;
context.Response.Cache.SetETag(getFileETag(context .Request.PhysicalPath));
context.Response.Cache.VaryByHeaders["ETag"] = true;
context.Response.WriteFile(context.Request.Physica lPath);
context.Response.End();
On subsequent GETs the If-Modified-Since header appears with the
Last-Modified date properly set. However, the ETag header never appears. The
function getFileETag creates a valid ETag string.
Why is ETag not being set or requested by subsequent GETs?
Your help is appreciated.
--
John H Clark
www.weownit.coop