我编写了一个在 SharePoint 中使用的处理程序,它将根据查询字符串中的给定参数生成 JSON 字符串。然后,JS 函数将使用此 JSON 字符串向客户端显示 HTML 中的相关数据,但是,该调用成本较高,并且希望将输出缓存一次。
该处理程序目前满足与 OUTPUT 缓存有关的所有内容,并在应用程序中进行了测试,取得了成果,但是,令我感到困惑的是,特别是在 SharePoint (2007) 中,“If-Modified-Since”标头属性从未出现,基本上总是出现返回为 null
。
我发现博客上的博客详细讨论了有关图像的问题,并包含文件,但我找不到有关页面(ASPX、AXD、ASHX)和处理程序自身的任何具体内容。
我在这里唯一的假设是我使用的是 AXD 文件,默认情况下 OUTPUT 缓存不直接支持该文件?
代码看起来像:
bool isModifiedSinceLast = (context.Request.Headers.Get("If-Modified-Since") != null)
: true
? false;
if (!isModifiedSinceLast)
{
context.Response.Headers.AppendHeader("If-Modified-Since", Guid.NewGuid());
}
else
{
// complete the call from cache
}
谢谢,
埃里克
I wrote a handler to be used within SharePoint that will generate a JSON string from a given parameter in the query-string. This JSON string will then be used by a JS function to display the relevant data in HTML to the client, however, the call is somewhat costly and would like to cache the output once.
The handler currently caters for everything regarding OUTPUT cache and tested within an application bares fruits, however, I'm baffled by the fact that, specifically in SharePoint (2007) the "If-Modified-Since" header attribute never appears, basically it always comes back as null
.
I found blog-on-blog that discuss this in length in regards to images, and include files but I can't find anything specific regarding this with pages (ASPX, AXD, ASHX) and the handler self.
My only assumption here is the fact that I'm using an AXD file, which is not directly supported by OUTPUT cache by default?
The code looks something like:
bool isModifiedSinceLast = (context.Request.Headers.Get("If-Modified-Since") != null)
: true
? false;
if (!isModifiedSinceLast)
{
context.Response.Headers.AppendHeader("If-Modified-Since", Guid.NewGuid());
}
else
{
// complete the call from cache
}
Thanks,
Eric
发布评论