Sign in to follow this  

[web] ASP.NET Advanced Caching

This topic is 3745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In order to fine-tune the caching process to my needs I use VaryByCustom="custom" directive in output caching. Now, I can return different key-strings to store different caching versions, but I want that in certain scenarios that caching to not to happen. What is the best way to not cache a particular version of a page?! Is there someway I can return a "special" key to invalidate caching? [Edited by - zaidgs on September 16, 2007 5:17:47 PM]

Share this post


Link to post
Share on other sites
Thank you capn_midnight for the link... I already know how to do the things described there, but I think I might not have been clear about what I want.

Consider the example they give in that article about caching different pages based on "Language" item found in a cookie. Check the code snippet they provided:

public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg.ToLower() == "cookies")
{
HttpCookie cookie = context.Request.Cookies["Language"];
if (cookie != null)
{
return cookie.Value;
}
}
return base.GetVaryByCustomString(context, arg);
}


Consider now the scenario that you want English, French, and German pages to be cached as expected, but that Spanish and Chinese pages to never get cached... How would I do that?

Share this post


Link to post
Share on other sites

This topic is 3745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this