AddCacheDependency or AddFileDependency?
What is the difference between Response.AddCacheDependency and Response.AddFileDependency in terms of implementing file dependency for cache? The following code seems to work in both cases, but which approach should I use?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim authorsDependency As New CacheDependency(Server.MapPath("authors.xml"))
Response.AddCacheDependency(authorsDependency)
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(True)
Response.Write(DateTime.Now.ToString())
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.AddFileDependency(Server.MapPath("authors.xml"))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(True)
Response.Write(DateTime.Now.ToString())
End Sub
+2
source to share
1 answer