虚拟路径提供程序禁用缓存?
我有一个虚拟路径提供者。问题是它缓存我的文件。每当我手动编辑它引用的 aspx 文件之一时,VPP 不会提取新文件,它会继续重用旧文件,直到我重新启动站点。
我什至在我的 VirtualPathProvider 类中重写了 GetCacheDependency():
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
return null;
}
想法?
I have a virtual path provider. Problem is its caching my files. Whenever I manually edit one of the aspx files it references the VPP doesn't pull in the new file, it continues to reuse the old file until I restart the site.
I've even over-rode the GetCacheDependency() in my VirtualPathProvider class:
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
return null;
}
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
返回 null 本质上是告诉 ASP.NET 您没有任何依赖项 - 因此 ASP.NET 不会重新加载该项目。
您需要的是返回有效的依赖项,例如,
更正确的方法是确保您只处理自己的缓存依赖项(这是一个示意性示例):
Returning a null is essentially telling ASP.NET that you do not have any dependency - hence ASP.NET will not reload the item.
What you need is to return a valid dependency e.g.
A more correct approach is to make sure that you only handle your own cache dependencies (this is a schematic example) :
禁用缓存的正确方法是:
The correct way to disable caching is this:
我不相信这就是原发帖者所问的。他想完全禁用缓存,而不是以更好的方式实现它,尽管您的帖子对后者有帮助。
许多人使用 VirtualPathProvider 从数据库而不是文件系统中提取数据。我不明白创建文件系统依赖项如何成为确定何时刷新文件的有用方法。
您如何强制它从不使用缓存并始终检索文件的最新版本?这就是问题所在。
I don't believe this is what the original poster asked. He wants to disable the caching entirely, not implement it in a better way, although your post is helpful for the latter.
A great many people are using VirtualPathProvider to pull data from a database instead of a file system. I don't see how creating a file system dependency would be a useful way to determine when it's time to refresh the file.
How would you FORCE it to never use caching and always retrieve the latest version of the file? That is the question.
根据需要为我工作的解决方案是:
但是,使用此解决方案会导致服务器挂起(Cassini、IIS 6、IIS 7、IIS 8)。悬挂只持续几分钟,然后结果就出来了。
我还对虚拟路径/文件进行了测试,结果相同。我搞乱了浏览器超时。
有人可以帮忙吗?
The solution that worked for me as desired was:
However, with this solution results in hanging the server (Cassini, IIS 6, IIS 7, IIS 8). The hanging only lasts for a few minutes then the results are delivered.
I've also included a test for virtual path/file with the same results. I messed with browser timeouts.
Can anyone help?