mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
Add HTTP/2 Push to Output Cache
This commit is contained in:
parent
7901300c30
commit
9100ba6673
|
@ -192,6 +192,7 @@
|
|||
<Compile Include="Code\MvcIntrinsics.cs" />
|
||||
<Compile Include="Code\Options\Locale.cs" />
|
||||
<Compile Include="Code\Options\Theme.cs" />
|
||||
<Compile Include="Code\OutputCachePushAttribute.cs" />
|
||||
<Compile Include="Controllers\ApiController.cs" />
|
||||
<Compile Include="Controllers\BaseController.cs" />
|
||||
<Compile Include="Controllers\FrontController.cs" />
|
||||
|
|
27
BuildFeed/Code/OutputCachePushAttribute.cs
Normal file
27
BuildFeed/Code/OutputCachePushAttribute.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using BuildFeed.Code.Options;
|
||||
|
||||
namespace BuildFeed.Code
|
||||
{
|
||||
public class OutputCachePushAttribute: ActionFilterAttribute
|
||||
{
|
||||
public override void OnResultExecuted(ResultExecutedContext filterContext)
|
||||
{
|
||||
bool isRtl = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft;
|
||||
Theme theme = new Theme(Theme.DetectTheme(filterContext.HttpContext));
|
||||
|
||||
filterContext.HttpContext.Response.PushPromise("/res/css/default.min.css");
|
||||
filterContext.HttpContext.Response.PushPromise(VirtualPathUtility.ToAbsolute(theme.CssPath));
|
||||
if (isRtl)
|
||||
{
|
||||
filterContext.HttpContext.Response.PushPromise("/res/css/rtl.min.css");
|
||||
}
|
||||
filterContext.HttpContext.Response.PushPromise("/res/ts/bfs.min.js");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public FrontController()
|
|||
|
||||
[Route("", Order = 1)]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> Index()
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ public async Task<ActionResult> Index()
|
|||
|
||||
[Route("page-{page:int:min(1)}/", Order = 0)]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> IndexPage(int page)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ public async Task<ActionResult> IndexPage(int page)
|
|||
[Route("group/{major}.{minor}.{number}.{revision}/", Order = 1)]
|
||||
[Route("group/{major}.{minor}.{number}/", Order = 5)] // for when there is no revision
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewGroup(uint major, uint minor, uint number, uint? revision = null)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ public async Task<ActionResult> ViewGroup(uint major, uint minor, uint number, u
|
|||
|
||||
[Route("build/{id:guid}/", Name = "Build")]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewBuild(Guid id)
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ public async Task<ActionResult> TwitterCard(long id)
|
|||
|
||||
[Route("lab/{lab}/", Order = 1, Name = "Lab Root")]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewLab(string lab)
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ public async Task<ActionResult> ViewLab(string lab)
|
|||
|
||||
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewLabPage(string lab, int page)
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ 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;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewSource(TypeOfSource source)
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ public async Task<ActionResult> ViewSource(TypeOfSource source)
|
|||
|
||||
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewSourcePage(TypeOfSource source, int page)
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ 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;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewYear(int year)
|
||||
{
|
||||
|
@ -263,7 +263,7 @@ public async Task<ActionResult> ViewYear(int year)
|
|||
|
||||
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewYearPage(int year, int page)
|
||||
{
|
||||
|
@ -289,7 +289,7 @@ 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;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewVersion(uint major, uint minor)
|
||||
{
|
||||
|
@ -298,7 +298,7 @@ public async Task<ActionResult> ViewVersion(uint major, uint minor)
|
|||
|
||||
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
|
||||
#if !DEBUG
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName;lang;theme"), OutputCachePush(Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> ViewVersionPage(uint major, uint minor, int page)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user