Help with Caching

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
 
S

Sam

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
 
J

Jonathan Wood

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
 

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,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top