Search code examples
asp.netcachingfragment-caching

Page caching issue in ASP.Net


We use page output caching in our ASP.Net website home page to make it appear load faster. The caching time is very minimum(5 minutes) so that the data updations are reflected to users within short time span. In the home page itself, We have a section called 'Polls' used for voting best answer for the question displayed. In this section, poll results are displayed when a user has already voted and for users who haven't voted, the poll question has to be displayed. The issue is, when a user who has already voted has visited the home page, the page is cached with poll results displayed. Within that 5 min's caching time, when another user who has not yet voted has accessed that page then for that user also results are only displayed instead of poll question so the user is not able to vote for that poll.

To prevent this, we have tried out data caching technique where datatable for all sections in home page is cached and the page is rendered. This technique still is not as fast as Page output caching and so our users does not desire this technique. The loading time for both data caching is much higher when compared to page output caching.

We have also tried out substitution caching method where a part of the page alone gets reloaded even when the entire page it cached. The most important issue in this caching method is we can use only HTML controls in that substitution control. We have tried creating polls section with HTML controls only, still we get problems with AJAX update panel used in other sections of the page.

Kindly guide me to resolve this issue. A part of the page(polls section) alone has to be reloaded for each user and other sections has to be delivered from cache. This should happen without compromising performance of the page.


Solution

  • I have implemented polls section of the page in an iframe, the content inside the iframe does not get cached. Simple, temporary solution!!!