Add response caching to metrics

This commit is contained in:
Timothy Baldridge 2021-11-30 23:06:00 -07:00
parent f8db7d4386
commit 46ee87553c
2 changed files with 4 additions and 0 deletions

View File

@ -108,6 +108,7 @@ public class MetricsController : ControllerBase
[HttpGet] [HttpGet]
[Route("report")] [Route("report")]
[ResponseCache(Duration = 60 * 60 * 4, VaryByQueryKeys = new [] {"action", "from", "to"})]
public async Task GetReport([FromQuery] string action, [FromQuery] string from, [FromQuery] string? to) public async Task GetReport([FromQuery] string action, [FromQuery] string from, [FromQuery] string? to)
{ {
var parser = new Parser(); var parser = new Parser();

View File

@ -63,6 +63,7 @@ public class Startup
services.AddSingleton<AuthorFiles>(); services.AddSingleton<AuthorFiles>();
services.AddSingleton<AuthorKeys>(); services.AddSingleton<AuthorKeys>();
services.AddSingleton<Client>(); services.AddSingleton<Client>();
services.AddResponseCaching();
services.AddSingleton(s => services.AddSingleton(s =>
{ {
var settings = s.GetService<AppSettings>()!; var settings = s.GetService<AppSettings>()!;
@ -109,6 +110,8 @@ public class Startup
app.UseService<DiscordWebHook>(); app.UseService<DiscordWebHook>();
app.UseService<Watchdog>(); app.UseService<Watchdog>();
app.UseResponseCaching();
app.Use(next => app.Use(next =>
{ {
return async context => return async context =>