Output caching temporarily disabled

Will need to fix so that it varies by language.
This commit is contained in:
Thomas Hounsell 2015-10-13 21:01:47 +01:00
parent fcf169c868
commit 684bd4f969
3 changed files with 43 additions and 41 deletions

View File

@ -27,13 +27,13 @@ public frontController() : base()
[Route("", Order = 1)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> index() { return await indexPage(1); }
[Route("page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> indexPage(int page)
{
@ -54,7 +54,7 @@ public async Task<ActionResult> indexPage(int page)
[Route("group/{major}.{minor}.{number}.{revision}/")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewGroup(byte major, byte minor, ushort number, ushort? revision = null)
{
@ -73,7 +73,7 @@ public async Task<ActionResult> viewGroup(byte major, byte minor, ushort number,
[Route("build/{id:guid}/", Name = "Build")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewBuild(Guid id)
{
@ -90,7 +90,7 @@ public async Task<ActionResult> viewBuild(long id)
[Route("twitter/{id}/")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none")]
// [OutputCache(Duration = 600, VaryByParam = "none")]
[CustomContentType(ContentType = "image/png", Order = 2)]
#endif
public async Task<ActionResult> twitterCard(Guid id)
@ -126,13 +126,13 @@ public async Task<ActionResult> twitterCard(Guid id)
[Route("lab/{lab}/", Order = 1, Name = "Lab Root")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewLab(string lab) { return await viewLabPage(lab, 1); }
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewLabPage(string lab, int page)
{
@ -158,13 +158,13 @@ public async Task<ActionResult> viewLabPage(string lab, int page)
[Route("source/{source}/", Order = 1, Name = "Source Root")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewSource(TypeOfSource source) { return await viewSourcePage(source, 1); }
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewSourcePage(TypeOfSource source, int page)
{
@ -190,13 +190,13 @@ public async Task<ActionResult> viewSourcePage(TypeOfSource source, int page)
[Route("year/{year}/", Order = 1, Name = "Year Root")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewYear(int year) { return await viewYearPage(year, 1); }
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewYearPage(int year, int page)
{
@ -222,13 +222,13 @@ public async Task<ActionResult> viewYearPage(int year, int page)
[Route("version/{major}.{minor}/", Order = 1, Name = "Version Root")]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewVersion(int major, int minor) { return await viewVersionPage(major, minor, 1); }
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> viewVersionPage(int major, int minor, int page)
{

View File

@ -143,7 +143,7 @@ public async Task<ActionResult> rss()
[Route("sitemap/")]
#if !DEBUG
[OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> sitemap()
{
@ -288,7 +288,7 @@ group b by b.Lab into lab
[Route("xml-sitemap/")]
#if !DEBUG
[OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> xmlsitemap()
{
@ -326,7 +326,7 @@ public async Task<ActionResult> xmlsitemap()
[Route("statistics/")]
#if !DEBUG
[OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
// [OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public async Task<ActionResult> stats()
{

View File

@ -6,34 +6,36 @@
namespace BuildFeed
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// Don't bother looking for the legacy aspx view engine.
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// Don't bother looking for the legacy aspx view engine.
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
DateTimeModelBinder db = new DateTimeModelBinder();
DateTimeModelBinder db = new DateTimeModelBinder();
ModelBinders.Binders.Add(typeof(DateTime), db);
ModelBinders.Binders.Add(typeof(DateTime?), db);
}
ModelBinders.Binders.Add(typeof(DateTime), db);
ModelBinders.Binders.Add(typeof(DateTime?), db);
}
public override string GetVaryByCustomString(HttpContext context, string custom)
{
switch(custom)
{
case "userName":
return context.User.Identity.Name.ToLower();
}
public override string GetVaryByCustomString(HttpContext context, string custom)
{
switch (custom)
{
case "userName":
return context.User.Identity.Name.ToLower();
case "lang":
return context.Request.Cookies["lang"].Value;
}
return "";
}
}
return "";
}
}
}