Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6663581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:30:54+00:00 2026-05-26T02:30:54+00:00

I have this action method: [OutputCache(Duration = 2, Location = OutputCacheLocation.Any, VaryByHeader = Accept-Charset)]

  • 0

I have this action method:

    [OutputCache(Duration = 2, 
                 Location = OutputCacheLocation.Any, 
                 VaryByHeader = "Accept-Charset")]
    public ActionResult Index()
    {
        return View();
    }

And the generated response is:

Cache-Control:public, max-age=2
Content-Length:5164
Content-Type:text/html; charset=utf-8
Date:Wed, 28 Sep 2011 16:30:33 GMT
Expires:Wed, 28 Sep 2011 16:30:35 GMT
Last-Modified:Wed, 28 Sep 2011 16:30:33 GMT
Server:Microsoft-IIS/7.5
Vary:*
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
X-Powered-By:ASP.NET

Why is the Vary header showing an asterisk instead of Accept-Charset ?

OutputCacheAttribute does have effect on the response, actually, the Expires and Cache-Control:max-age=n headers depends on the Duration argument, and the Cache-Control:public/private/no-cache depends on the Location argument.

I have created a wrapper for OutputCacheAttribute to see what is going on:

public class CustomOutputCacheAttribute:OutputCacheAttribute
{
    public override void OnResultExecuted(ResultExecutedContext filterContext)
    {
        base.OnResultExecuted(filterContext);

        Dictionary<String, String> headers = new Dictionary<string, string>();
        foreach (var header in filterContext.HttpContext.Response.Headers.AllKeys)
            headers.Add(header, filterContext.HttpContext.Response.Headers[header]);

        Debugger.Break();
    }
} 

The headers are not shown in the break, so probably what OutputCacheAttribute does is configure HttpContext.Current.Response.Cache.

I can see how filterContext.HttpContext.Response.Cache.VaryByHeaders.UserCharSet is true, and for example filterContext.HttpContext.Response.Cache.VaryByHeaders.AcceptTypes is false, but the Vary header always says *.

I am wondering if the only possible values are the four ones listed as properties of filterContext.HttpContext.Response.Cache.VaryByHeaders, could it be?

Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:30:54+00:00Added an answer on May 26, 2026 at 2:30 am

    The solution is use Response.Cache.SetOmitVaryStar(true)

        [OutputCache(Duration = 2,
             Location = OutputCacheLocation.Any,
             VaryByHeader = "Accept-Charset")]
        public ActionResult Index()
        {
            Response.Cache.SetOmitVaryStar(true);
            return View("ShowHeaders");
        }
    

    I am still trying to figure out what is wrong with Vary:* in this thread: What is the meaning of the HTTP header Vary:*

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this action method in C#: public ActionResult Index() { ViewBag.Message = Hello;
I have a simple MVC3 Controller Action like this [HttpGet] [OutputCache(Duration = 1200,Location=System.Web.UI.OutputCacheLocation.Server)] public
I have this action method: [HttpPost] public ActionResult GetNextImage(int m_id) { ... return Json(new{...});
I have an MVC controller that has this Action Method: [HttpPost] public ActionResult SubmitAction()
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
I have an iframe and the source is a controller action method. This action
So I have an MVC Action in my controller public System.Web.Mvc.ActionResult Link(LinkType type) {
i have this form: <form action = method = get> <input type = input
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
I have to do through Action like this: Action action = () => {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.