【问题标题】:How can i store something in the application cache for an unlimited amount of time?我怎样才能在应用程序缓存中无限期地存储一些东西?
【发布时间】:2018-01-31 02:33:37
【问题描述】:

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

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

【问题讨论】:

  • 在iis重启或recicle时会被清除,你需要保存到数据库或文件中以便稍后恢复

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


【解决方案1】:

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

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

请参阅this 了解更多信息。

【讨论】:

  • @John Staurt 如果它对您有帮助,请点赞并接受这个答案,这样人们就知道这是正确的答案并帮助他们。
猜你喜欢
  • 2019-08-24
  • 1970-01-01
  • 2012-11-22
  • 1970-01-01
  • 2016-02-14
  • 1970-01-01
  • 1970-01-01
  • 2011-01-31
  • 1970-01-01
相关资源
最近更新 更多