User Control Question

R

Roshawn Dawson

Hi All,

I've decided to code a web user control that uses the ASP.NET Repeater
control to render the output. This web user control obtains its data
from a web service. If I were to use fragment caching (<%@ OutputCache
Duration="3600" %>) with this control, will it call the web service each
time the page is requested or will it continue to use the web service
data until the cache duration expires?

I'd like to know as I'm trying to minimize the total number of requests
to the web service.

Thanks,

Roshawn
 
D

Derek Harmon

Roshawn Dawson said:
This web user control obtains its data from a web service. If I were to use
fragment caching (<%@ OutputCache Duration="3600" %>) with this control,
will it call the web service each time the page is requested or will it continue to
use the web service data until the cache duration expires?

The answer is Yes, output caching the user control (fragment caching) will
reduce the number of calls you're making to the web service.

Fragment caching produces the HTML from the user control the first-time it
gets requested which will include calling your web service. Thereafter, until
the fragment of HTML associated with your user control in the output cache
expires, ASP.NET will render the HTML that's been stored (and not perform
any dynamic processing of your user control, therefore it would not call the
web service). When the fragment in the cache expires, and a request comes
in that requires the HTML of your user control, then ASP.NET will again
perform the dynamic processing in your control (including a call to the web
service) to create a refreshed fragment which it will then return (and cache)
for another 3,600 seconds.


Derek Harmon
 

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

Top