OutputCache directive vs Response.Cache.SetCacheability

P

Pete Griffiths

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top