Is Caching disabled by default ???

G

Girish

I have a usercontrol showing some generic information across multiple
screens. As per MS, caching is disabled by default so i didn't put a
@OutputCache directive in my control. I found the control being cached at
several occassions so was forced to put some code to disable caching
explicitely. Here are the lines of code i put to stop the control from being
cached:

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Expires = -1
Response.Cache.SetNoStore()

But even now i see instances where the data on the control seems to be
caching and users see each other's data on this control. Can anyone please
help me find if i am doing something wrong here.
 
J

Joerg Jooss

Girish said:
I have a usercontrol showing some generic information across multiple
screens. As per MS, caching is disabled by default so i didn't put a
@OutputCache directive in my control. I found the control being
cached at several occassions so was forced to put some code to
disable caching explicitely. Here are the lines of code i put to stop
the control from being cached:

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Expires = -1
Response.Cache.SetNoStore()

But even now i see instances where the data on the control seems to
be caching and users see each other's data on this control. Can
anyone please help me find if i am doing something wrong here.

You're confusing fragment caching with HTTP caching. Your code controls
HTTP caching, thus affecting the whole page. Because your page was
cacheable before you added these lines, it must have seemed as though
the controls were cached -- but it was most likely the entire page.

Cheers,
 

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,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top