【发布时间】:2018-01-31 02:33:37
【问题描述】:
如何在应用程序缓存中无限期存储内容?
我已尝试使用 HttpContext.Application["foo"] = bar 存储数据。但是这些数据会在一段时间后被清除。
【问题讨论】:
-
在iis重启或recicle时会被清除,你需要保存到数据库或文件中以便稍后恢复
标签: asp.net-mvc caching asp.net-mvc-5
如何在应用程序缓存中无限期存储内容?
我已尝试使用 HttpContext.Application["foo"] = bar 存储数据。但是这些数据会在一段时间后被清除。
【问题讨论】:
标签: asp.net-mvc caching asp.net-mvc-5
您可以在web config 中为它添加很好的过期时间,如下所示:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires"
httpExpires="Tue, 22 Aug 2037 12:00:00 GMT" />
</staticContent>
</system.webServer>
</configuration>
请参阅this 了解更多信息。
【讨论】: