Home > C# > ASP.NET WebForms LazyPanel: Dealing with output cache

ASP.NET WebForms LazyPanel: Dealing with output cache

In a previous post I introduced you LazyPanel. Now I will talk about how it deals with output cache.
The main problem with output cache is when the cached response is retrieved, the content key is expired:

  • Request comes
  • Server processes the request
  • LazyPanel caches for 3 seconds it’s content and generates a key
  • Server returns the response without the lazy content but with an ajax call for retriving it
  • Request comes for the content with the generated key
  • Server returns the content and removes it from the cache
  • A new Request comes
  • Server retrieves it from the output cache
  • Reqeust comes for the content with the previously generated key
  • Server crashes because the key doesn’t exist 😥

Ideally, the content cache should take in care the same stuff that the output cache does, so instead of living 3 seconds, it lives the same time for the same circumstances. Well… “let’s see the code of the output cache” I said… and of course it is all sealed, internal and all the crap. F**k.

I opened the reflector and check the code. I realized that the output cache is stored in the web cache known by all of us and the key is generated using all output cache vars (params, encoding, etc). So, I copied (yes, copied) the strategy for creating the key and use it for storing the content cache. Finally, the duration of the cache is the same of the output cache and it seems to be working perfectly 🙂

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: