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 6167247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:28:39+00:00 2026-05-23T22:28:39+00:00

I have an asp.net mvc 3 project and I have a home controller. I

  • 0

I have an asp.net mvc 3 project and I have a home controller. I have tagged my Index action with this attribute:

[OutputCache(Location = System.Web.UI.OutputCacheLocation.Any, Duration = 120, VaryByParam = "*", VaryByCustom = "user")]
public ActionResult Index()
{
    return View();
}

The vary by custom with user is handled in Global.asax.cs to check the user cookie value so that caching changes based on whether the user is logged in or not and what user they are.

When I go to this page on my web server, I get these headers in the response:

Cache-Control   public, max-age=120
Content-Type    text/html; charset=utf-8
Content-Encoding    gzip
Expires Sun, 20 Mar 2011 21:50:09 GMT
Last-Modified   Sun, 20 Mar 2011 21:48:09 GMT
Vary    Accept-Encoding
Date    Sun, 20 Mar 2011 21:48:09 GMT
Content-Length  3105

Right off the bat, the Vary – Accept-Encoding value looks wrong, shouldn’t it have sent a Vary – * instead?

I am rendering the User.Identity.Name property to this view as well and I am noticing that even when I log out it will still render the user name, until the 120 seconds expires.

public override string GetVaryByCustomString(HttpContext context, string custom)
{
    if (custom.Equals("user", StringComparison.OrdinalIgnoreCase))
    {
        HttpCookie cookie = context.Request.Cookies["user"];
        if (cookie != null)
        {
            return cookie.Value;
        }
    }
    return base.GetVaryByCustomString(context, custom);
}

Been playing with this for several hours, and am completely stuck, hopefully someone has an idea…

  • 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-23T22:28:40+00:00Added an answer on May 23, 2026 at 10:28 pm

    You can have IIS compress the response before it gets cached by setting dynamicCompressionBeforeCache="true" on the urlCompression element in your web.config. This will result in the expected Vary:* header being returned.

    Excerpt, from the IIS Configuration Reference, about the dynamicCompressionBeforeCache attribute:

    The dynamicCompressionBeforeCache attribute specifies whether IIS will dynamically compress content that has not been cached. When the dynamicCompressionBeforeCache attribute is true, IIS dynamically compresses the response the first time a request is made and queues the content for compression. Subsequent requests are served dynamically until the compressed response has been added to the cache directory. Once the compressed response is added to the cache directory, the cached response is sent to clients for subsequent requests. When dynamicCompressionBeforeCache is false, IIS returns the uncompressed response until the compressed response has been added to the cache directory.

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

Sidebar

Related Questions

I have a Asp.net MVC 2 project. My start page has following link: http://localhost:2666/Home/Index?SomeID=4f62c452-4513-4dd0-b235-830d721815e4
I have a new asp.net mvc 3 project with following structure: Views: /Home/Index.cshtml @{
I have this ASP.net MVC project that requires a wizard like interface... So I
I have an ASP.NET MVC project with a form. In the Action method that
I have an ASP.NET MVC project and I have a single action that accepts
I have opened a sample ASP.NET MVC project. In HomeController I have created a
I have ASP.Net MVC project. Plus wordpress blog under a subfolder /Blog. Now, when
I have an ASP.NET MVC project with xVal and data annotations and I need
We have an ASP.Net MVC project that will start with a single web server
I have an Asp.net MVC project that modestly uses jQuery scripts. My views also

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.