Here's my cache directive:
<%@ OutputCache Duration="3600" VaryByParam="none"
VaryByCustom="IndexPage" Location="Server" %>
I added a simple time stamp to the page so I could see it working.
Caching works fine when not adding cookies. I can go to different
machines and open and close browsers and the timestamp remains the
same, verifying that caching is working.
Now, when I add a cookie to the response, the cache resets itself, but
only after I close the browser, or when I go to a different machine
and hit the page.
Any ideas? Is this by design?
I frequently add cookies to the response, often enough so that if this
is by design, caching will be of little use.
Thanks,
Jeff
Jeff Marken - 25 Jan 2004 20:42 GMT
Folks,
I have played around with this a lot more, and have the same problem,
but know what it is, so can refine my question. I need a way to get
around this problem...
I cache a heavily accessed ASPX page. It's sortable in several ways,
and when the user clicks a sorting link, a query string parameter is
used to specify the sort key. I use cookies to remember the sort key
so that the user can go elsewhere on or off the site and return to
this page and the sort preference will be retained.
When the user clicks a different sorting key, the server sees the key
in the URL and uses it to return the cached version of that page if
applicable, but when it does, since the cached page is returned, the
cookie for the new sorting key is not returned. I tried adding the
cookie to cookies collection in the request object when
'GetVaryByCustomString' is invoked, but the cookie doesn't actually
make it out of the server if it finds the page in cache.
How can I force the cookie to go out even if a cached page is actually
returned? Is there some other method I can override to do this? Do I
need to use an HttpModule or HttpHandler to set the cookies, and if
so, will this interefere with the caching mechanis an ASP.NET?
Any help would be appreciated!
Jeff
> Here's my cache directive:
>
[quoted text clipped - 19 lines]
>
> Jeff