如何在应用程序缓存中存储一​​些内容无限期?

时间:2017-08-22 17:39:07

标签: asp.net-mvc caching asp.net-mvc-5

如何在应用程序缓存中存储无限量的内容?

我尝试使用HttpContext.Application存储数据[" foo"] = bar。但这段数据会在一段时间后被清除。

1 个答案:

答案 0 :(得分:0)

您可以在web config中添加很好的到期时间,如下所示:

<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="UseExpires"
            httpExpires="Tue, 22 Aug 2037 12:00:00 GMT" />
      </staticContent>
   </system.webServer>
</configuration>

有关详细信息,请参阅this