Help with Caching

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

I've seen a lot of people bit by caching besides myself. It seems rather
difficult to have much caching in a dynamic site, without it causing
problems.

At any rate, I have a page that lists items from the database. It's the main
page of my site so I added the following line:

<%@ OutputCache Duration="60" VaryByParam="*" %>

In most cases, this appears to work just fine. However, there is a search
box on this page and it doesn't work because when the user clicks Go, the
postback is not processed if the page is being cached.

Is there any way around this without having to remove caching for this page?

Thanks.

Jonathan
 
I've seen a lot of people bit by caching besides myself. It seems rather
difficult to have much caching in a dynamic site, without it causing
problems.

At any rate, I have a page that lists items from the database. It's the main
page of my site so I added the following line:

<%@ OutputCache Duration="60" VaryByParam="*" %>

In most cases, this appears to work just fine. However, there is a search
box on this page and it doesn't work because when the user clicks Go, the
postback is not processed if the page is being cached.

Is there any way around this without having to remove caching for this page?

Thanks.

Jonathan


You probably do not want to cache the entire page then. ASP.NET also
supports Data Caching and Fragment Caching where you can cache either
the data used to render a page or just a portion of a page. To use
Fragment Caching you must essentially break you page down into User
Controls and the content of the User Control is cached. Check out the
quickstarts:

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/default.aspx

Thanks,

Sam
 
Sorry for the delayed response. Thanks for the tip and the link. There is
definitely a lot to learn about ASP.NET caching.

I've seen a lot of people bit by caching besides myself. It seems rather
difficult to have much caching in a dynamic site, without it causing
problems.

At any rate, I have a page that lists items from the database. It's the
main
page of my site so I added the following line:

<%@ OutputCache Duration="60" VaryByParam="*" %>

In most cases, this appears to work just fine. However, there is a search
box on this page and it doesn't work because when the user clicks Go, the
postback is not processed if the page is being cached.

Is there any way around this without having to remove caching for this
page?

Thanks.

Jonathan


You probably do not want to cache the entire page then. ASP.NET also
supports Data Caching and Fragment Caching where you can cache either
the data used to render a page or just a portion of a page. To use
Fragment Caching you must essentially break you page down into User
Controls and the content of the User Control is cached. Check out the
quickstarts:

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/default.aspx

Thanks,

Sam
 
Back
Top