<script language="CS" runat="server">
protected override void OnLoad(EventArgs e)
{
if (Request.QueryString["ClearCache"] != null)
{
Sitecore.Context.Database = this.WebContext.Database;
Sitecore.Context.Database.Engines.TemplateEngine.Reset();
Sitecore.Context.ClientData.RemoveAll();
Sitecore.Caching.CacheManager.ClearAllCaches();
Sitecore.Context.Database = this.ShellContext.Database;
Sitecore.Context.Database.Engines.TemplateEngine.Reset();
Sitecore.Caching.CacheManager.ClearAllCaches();
Sitecore.Context.ClientData.RemoveAll();
InfoLiteral.Text = "All sitecore cache has been cleared. DateTime:" + DateTime.Now.ToString();
}
else
{
InfoLiteral.Text = "You haven't entered correct query parameter. DateTime:" + DateTime.Now.ToString();
}
base.OnLoad(e);
}
private Sitecore.Sites.SiteContext WebContext
{
get
{
return Sitecore.Configuration.Factory.GetSite(Sitecore.Configuration.Settings.GetSetting("stagingSiteContext", "website"));
}
}
private Sitecore.Sites.SiteContext ShellContext
{
get
{
return Sitecore.Configuration.Factory.GetSite("shell");
}
}
</script>
Enjoy!
No comments:
Post a Comment