1

Let's assume the following code:

[OutputCache(Duration=60,VaryByCustom="Browser")]
public ActionResult CachableAction(string SomeParameter)
{
   return View();
}

I know that Output caching lets you store the output of an action method in memory on the Web server. For example, if the action method renders a view, the view page will be cached.

I don't want to cache my pages in Debug configuration.

What settings are need for to apply cache only in Release configuration not Debug ?

I'm using VS2010.

3 Answers 3

3

For attributes, you could just go for using preprocessor directive

#if !DEBUG
[OutputCache(Duration=60,VaryByCustom="Browser")]
#endif
public ActionResult CachableAction(string SomeParameter)
{
   return View();
}
Sign up to request clarification or add additional context in comments.

Comments

2

The web.config.debug file is used only when you build a deployment package. If you run your site locally in Cassini for example it is completely ignored. So you may try disabling cache in your web.config:

<caching>
    <outputCache enableOutputCache="false" />
</caching>

and in your web.config.release enable the cache. Note though that if you don't use the web deployment package feature those files are completely ignored.

Comments

0

this i am doing in my testing project in my controller i do like this in below

[OutputCache(Duration = 10, VaryByParam = "ParamA;ParamB;")]
        public PartialViewResult CachData(string someparameter)
        {
            string returnvalue = string.Format("parameter :{0} date : {1}", someparameter, DateTime.Now.ToString());
            return PartialView("CachData", returnvalue);
        }

and in my view

@model string 
<p>
    This is my cach Action</p>
@Html.Raw(Model)

i think this will help you...

1 Comment

And where is the setting for Release configuration ? I don't want to cache my pages in Debug mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.