asp.net-mvc – 如何在ASP.NET Core中启用ClientCache

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 如何在ASP.NET Core中启用ClientCache前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在ASP.net 4.5中,我们曾经能够通过在web.config中添加“ClientCache”来启用静态资源上的expires头(反过来,启用浏览器缓存),例如:
<staticcontent>
  <clientcache cachecontrolmode="UseMaxAge" cachecontrolmaxage="365.00:00:00" />
</staticcontent>

http://madskristensen.net/post/cache-busting-in-aspnet中所述

当我们没有web.config和Startup.cs时,我们现在如何在ASP.net 5中执行此操作?

解决方法

在Startup.cs>配置(IApplicationBuilder applicationBuilder,…..)
applicationBuilder.UseStaticFiles(new StaticFileOptions
{
     OnPrepareResponse = context => 
     context.Context.Response.Headers.Add("Cache-Control","public,max-age=2592000")
});
原文链接:https://www.f2er.com/netcore/247788.html

猜你在找的.NET Core相关文章