我有一个类似于AssemblyResourceLoader的IHttpHandler。它所做的是生成一个图像,然后将其发送回浏览器。
在AssemblyResourceLoader中有一个代码块,如下所示:
HttpCachePolicy cache = context.Response.Cache;
cache.SetCacheability(HttpCacheability.Public);
cache.VaryByParams["d"] = true;
cache.SetOmitVaryStar(true);
cache.SetExpires(DateTime.Now + TimeSpan.FromDays(365.0));
cache.SetValidUntilExpires(true);
Pair assemblyInfo = GetAssemblyInfo(assembly);
cache.SetLastModified(new DateTime((long) assemblyInfo.Second));我已经将我的设置为发出与AssemblyResourceLoader完全相同的标头。我设置了Last-Modified标头,浏览器将If-Modified- set标头发送给我的处理程序,就像它对AssemblyResourceLoader所做的那样。问题是:我的处理程序从不像AssemblyResourceLoader那样返回304。我在AssemblyResourceLoader代码中找不到处理If-Modified- myself头的地方,所以我不知道自己该如何处理它。有人知道ASP.Net在哪里做这件事吗?我怎样才能从我的处理程序中获得相同的行为?
谢谢。
发布于 2010-02-05 02:00:27
看起来你需要自己来做,但这并不难:http://www.motobit.com/tips/detpg_net-last-modified/
https://stackoverflow.com/questions/2201781
复制相似问题