我想缓存我的图像,然后找到类似这样的东西
<cache enabled="true"> Current Time Inside Cache Tag Helper: @DateTime.Now </cache>
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/cache-tag-helper?view=aspnetcore-3.1我如何在上面实现我的镜像?
发布于 2019-12-14 05:26:38
图片缓存是客户端缓存,你应该像下面这样配置你的应用:
app.UseStaticFiles(new StaticFileOptions
{
ServeUnknownFileTypes = false,
OnPrepareResponse = ctx =>
{
const int durationInSeconds = 60 * 60 * 24;
ctx.Context.Response.Headers[HeaderNames.CacheControl] = "public,max-age=" + durationInSeconds;
ctx.Context.Response.Headers[HeaderNames.Expires] = new[] { DateTime.UtcNow.AddYears(1).ToString("R") }; // Format RFC1123
}
});https://stackoverflow.com/questions/59251391
复制相似问题