1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-09 00:41:37 +01:00

no response cache. manual CacheControl middleware

This commit is contained in:
Kyle Spearrin 2018-06-18 13:35:46 -04:00
parent 7ee659e3b1
commit 18b7bcb9e3
2 changed files with 12 additions and 3 deletions

View File

@ -28,7 +28,6 @@ namespace Bit.Icons.Controllers
} }
[HttpGet("{hostname}/icon.png")] [HttpGet("{hostname}/icon.png")]
[ResponseCache(Duration = 604800 /*7 days*/)]
public async Task<IActionResult> Get(string hostname) public async Task<IActionResult> Get(string hostname)
{ {
if(string.IsNullOrWhiteSpace(hostname) || !hostname.Contains(".")) if(string.IsNullOrWhiteSpace(hostname) || !hostname.Contains("."))

View File

@ -2,8 +2,10 @@
using Bit.Icons.Services; using Bit.Icons.Services;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Net.Http.Headers;
namespace Bit.Icons namespace Bit.Icons
{ {
@ -31,7 +33,6 @@ namespace Bit.Icons
{ {
options.SizeLimit = iconsSettings.CacheSizeLimit; options.SizeLimit = iconsSettings.CacheSizeLimit;
}); });
services.AddResponseCaching();
// Services // Services
services.AddSingleton<IDomainMappingService, DomainMappingService>(); services.AddSingleton<IDomainMappingService, DomainMappingService>();
@ -50,7 +51,16 @@ namespace Bit.Icons
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
app.UseResponseCaching(); app.Use(async (context, next) =>
{
context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue
{
Public = true,
MaxAge = TimeSpan.FromDays(7)
};
await next();
});
app.UseMvc(); app.UseMvc();
} }
} }