Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MemoryCacheEntryOptions缓存在AbsoluteExpirationRelativeToNow过期后未清除_C#_Asp.net_Caching - Fatal编程技术网

C# MemoryCacheEntryOptions缓存在AbsoluteExpirationRelativeToNow过期后未清除

C# MemoryCacheEntryOptions缓存在AbsoluteExpirationRelativeToNow过期后未清除,c#,asp.net,caching,C#,Asp.net,Caching,我已将示例webapp部署到Azure。应用程序使用MemoryCacheEntryOptions缓存一个变量,以存储一个值(来自数据库),该值将在5分钟内过期 然而,通过Chrome调试工具5分钟后,我仍然可以查询缓存、预期为空的缓存值或当前存储在数据库中更新的任何新值 我甚至尝试在web浏览器中清除缓存,但缓存似乎仍保留以前的值 但是,当我重新启动网站并再次打开web应用程序时,缓存值不再存在 Azure中的任何设置都会影响缓存到期吗 private readonly MemoryCache

我已将示例webapp部署到Azure。应用程序使用MemoryCacheEntryOptions缓存一个变量,以存储一个值(来自数据库),该值将在5分钟内过期

然而,通过Chrome调试工具5分钟后,我仍然可以查询缓存、预期为空的缓存值或当前存储在数据库中更新的任何新值

我甚至尝试在web浏览器中清除缓存,但缓存似乎仍保留以前的值

但是,当我重新启动网站并再次打开web应用程序时,缓存值不再存在

Azure中的任何设置都会影响缓存到期吗

private readonly MemoryCacheEntryOptions _cacheEntryOptions;
protected CacheService(IMemoryCache memoryCache)
{
    _ memoryCache = memoryCache;
 _cacheEntryOptions = new MemoryCacheEntryOptions
  { 
    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300)
  };
}

调试web应用程序的行为是出了名的困难,因为您所能控制的只是浏览器,而且您永远不会获得独占访问权


即使您没有刷新页面,也可能有很多东西查询了服务器。罪魁祸首从“任何搜索引擎webcrawler”开始,以“某种程度上具有攻击性的安全工具”结束(因为有些病毒可能使用web服务器)。您可以尝试缩短超时时间的方法。但理想情况下,您希望让您访问它的服务器和客户端都在单独的虚拟机中运行,这些虚拟机仅通过虚拟机监控程序连接。这样,您就可以确定没有人在干预。

您创建了一个
MemoryCacheEntryOptions
并将其保存到字段中,但从不使用它。设置没有附加到内存缓存您的代码似乎有点凌乱。只有在调用
IMemoryCache.Set
方法时,才应该创建
MemoryCacheEntryOptions
的实例。这些选项必须实例化,并且仅当您希望在缓存中保存某些内容时才使用。此外,web浏览器缓存与服务器端内存缓存无关。服务器端应用程序缓存功能与web浏览器HTTP缓存之间没有关系。如何使用Google Chrome开发工具验证服务器端代码的行为?