[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

OutputCache directive vs Response.Cache.SetCacheability

Pete Griffiths

2/16/2006 9:48:00 AM

Hi folks,

I have an infuriating problem. I have a number of pages that I want to cache
server-side only, using varybycustom. I have implemented a
GetVaryByCustomString in my global.asax. I am setting the caching behaviour
in the Page_Load as follows:

Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)
Response.Cache.SetValidUntilExpires(True)

Response.Cache.SetVaryByCustom("report.aspx")

Response.Cache.SetExpires(Info.PageCacheExpires)

(where Info.PageCacheExpires is a specific time for this instance of the
page).

My problem is that this works most of the time, but occasionally it just
stops working - the page is rendered on every request (and the
Global.GetVaryByCustomString stops getting called). The only way to fix this
is to add an OutputCache directive to the page, at which point the caching
works reliably. The problem here though is that the Duration attribute
(which is required) of the directive overrides the value I'm setting in
Response.Cache.SetExpires.

Any thoughts?

(this is asp.net 1.1)

Pete Griffiths