protected void HomePage_Load(object sender, System.EventArgs e)
{
if (SiteConfig.EnableStartPageCaching && Request.QueryString != null && Request.QueryString["page"] != "admin")
{
hideAdminTools = true;
double seconds = 86400; //max 86400 seconds = 24 hours
// only the default site without any querys will have an expiration
// time in seconds to the end of day, with query the site will expire
// after 24 hours
if (Request.QueryString != null && Request.QueryString.Count == 0)
{
DateTime time = DateTime.Now;
DateTime timeEnd = new DateTime(time.Year, time.Month, time.Day, 23, 59, 59);
TimeSpan endTimeSpan = new TimeSpan(timeEnd.Ticks - time.Ticks);
seconds = endTimeSpan.Hours * 60 + endTimeSpan.Minutes * 60 + endTimeSpan.Seconds;
}
Response.Cache.SetExpires(DateTime.Now.AddSeconds(seconds));
Response.Cache.VaryByParams["*"] = true;
Response.Cache.VaryByHeaders["Accept-Language"] = true;
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
// insert something into the cache so that we can invalidate it when a new entry or comment is made
this.DataCache.Insert("BlogCoreData", "BlogCoreData", System.Web.Caching.CacheItemPriority.NotRemovable);
Response.AddCacheItemDependency("BlogCoreData");
Response.AddFileDependency(SiteConfig.GetConfigFilePathFromCurrentContext());
}
}