清除部分输出缓存
我有一个页面,其中包含输出缓存(部分输出缓存)的控件。这些设置如下:
[PartialCaching(86400, null, null, "campaign.whatwhere", true)]
public partial class controls_LatestEnquiriesListCached : System.Web.UI.UserControl
{
...
如何
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "campaign.whatwhere")
{
return (CampaignManager.CurrentCampaign.DefaultWorkTypeId ?? 0).ToString() + (CampaignManager.CurrentCampaign.DefaultEnquiryAreaId ?? 0).ToString();
}
return base.GetVaryByCustomString(context, custom);
}
在 Global.asax
中,
设置才能清除特定页面上的此输出缓存?
是否可以像 MyPageWithCachedControl.aspx?ClearCache=true
这样设置???
I have a page that has controls that are output caches (partial output caching). These are setup like this:
[PartialCaching(86400, null, null, "campaign.whatwhere", true)]
public partial class controls_LatestEnquiriesListCached : System.Web.UI.UserControl
{
...
With
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "campaign.whatwhere")
{
return (CampaignManager.CurrentCampaign.DefaultWorkTypeId ?? 0).ToString() + (CampaignManager.CurrentCampaign.DefaultEnquiryAreaId ?? 0).ToString();
}
return base.GetVaryByCustomString(context, custom);
}
In Global.asax
How can I setup so I can clear this output cache on a specific page?
Is it possible to setup like MyPageWithCachedControl.aspx?ClearCache=true
???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以创建一个除了清除缓存之外不执行任何操作的 aspx 页面。您可以获取查询字符串参数并让它通过缓存键删除。
或者您可以尝试查找 ASP.NET 缓存管理器。
You can create an aspx page that does nothing but clears cache. You can take the querystring parameter and have it delete by cache key.
Or you can try to find and ASP.NET cache manager.
您应该使用 HttpResponse.RemoveOutputCacheItem(path) 清除输出缓存,其中 path 是 https://stackoverflow.com/a/37167/30594
You should use
HttpResponse.RemoveOutputCacheItem(path)
to clear the output cache where path is the virtual absolute path of the user control as specified in the https://stackoverflow.com/a/37167/30594使用 HTTPResponse.RemoveOutputCacheItem(pathofpage) 清除特定页面的缓存。
例如:
Use
HTTPResponse.RemoveOutputCacheItem(pathofpage)
to clear the cache of a particular page.For example: