1st time where outputcaching make problems

i an my classes i tell my students that caching and espacially outputcaching are wonderfull features which should be used as often as you can.

Now i had a problem in conjunction with the loginstatus control. If you are logged in, a logout link is displayed and if you are anonymous a login link is displayed which directs the user to the login page.

 On this page caching was set to a very large time, cause of other displayed data. When the user clicks "sign out" nothing happens. When he change to other pages he seems to be logged out. The reason was that the IIS caches the pages and send a 304 command which says the Browser to display the "old" page.

My solution is to add the cookie as parameter

<%@ OutputCache VaryByParam="none" Duration="600" VaryByHeader="Cookie" %>

Its not perfect cause if you are working with data in cookies (which is not best) then caching will not work.

 

Published Monday, May 22, 2006 8:59 PM by preishuber
Filed under: ,

Comments

# re: 1st time where outputcaching make problems

Tuesday, July 18, 2006 2:43 PM by dan

I am having the exact same problem. Is there a better solution than varybyheader="cookie". I tried this solution and at first thought it solved my problem, but then during tests, i realized that the page is no longer being cached globally (for any user) but only for each unique user.  That defeats the benifit of the cache in the first place.

Leave a Comment

(required) 
(required) 
(optional)
(required)