Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] ASP.NET Advanced Caching

Started by zaidgs Sep 16, 2007 at 9:33 AM 1 replies 900+ views
Original Post
zaidgs
zaidgs
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]
zaidgs
zaidgs
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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.