开发者

With cacheduration set, is it possible to have the function still trigger

开发者 https://www.devze.com 2022-12-30 00:56 出处:网络
If I have my cacheduration set to some value for my Web Service, is it possible to for开发者_开发问答ce the function to trigger?

If I have my cacheduration set to some value for my Web Service, is it possible to for开发者_开发问答ce the function to trigger?

Thanks.


The only way you could force it is to send a no-cache header to the server.

For information view the MSDN Documentation, specifically the remarks, quoted below.

In addition, HTTP indicates that a user agent (the browser or calling application) should be able to override server caching by setting the "Cache-Control" to "no-cache". ASP.NET applications, therefore, ignore cached results when they find a "no-cache" header.


Here's the pattern I typically use. If the item exists in the cache you use it otherwise you create it and store it in the cache:

Dim Obj = Cache("YourKeyHere")
Dim YourObj As DataSet
If Obj IsNot Nothing AndAlso TypeOf Obj Is DataSet Then
    YourObj = DirectCast(Obj, DataSet)
Else
    YourObj = New DataSet()
    '...do your normal loading of your object here
    Cache.Insert("YourKeyHere", YourObj)
End If

If instead you want to be notified when your cache expires you can use the onUpdateCallback

0

精彩评论

暂无评论...
验证码 换一张
取 消