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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:24:45+00:00 2026-06-14T22:24:45+00:00

Question about settings of IIS7. How I can do one cache for each of

  • 0

Question about settings of IIS7. How I can do one cache for each of bindings? For example, I have one site and three bindings for the site. I need to create three different caches for each of three bindings.

  • 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-06-14T22:24:47+00:00Added an answer on June 14, 2026 at 10:24 pm

    usr’s answer is correct if you are manually reading from and writing to the cache. You have less direct control over the cache key with the OutputCacheAttribute, however.

    Note that the OutputCacheAttribute still relies on cache keys in its implementation. In ASP.NET, each item that is cached is assigned a key through which it is looked up.

    When you call a Controller Action that has an OutputCacheAttribute, a cache key is generated based on your request; for instance, if you have some VaryByParam designations, cache keys can differ for each user. Then the response your Action returns is stored in the cache under that key.

    When the next request comes in, the cache key is generated and we check in the cache to see if there is already something cached under that key. If so, we just return that; otherwise, we continue with the Action.

    We can have a different cache for each binding by including the host name in the cache key. If you’re using OutputCacheAttribute, you can override it to allow varying the cache by host:

    public override string GetVaryByCustomString(HttpContext context, string customVary)
    {
        if(customVary == "Host")
        {
            return context.Request.Url.Host;
        }
        // other behaviors here if necessary
        return "";
    }
    

    This will allow the cache key to be dynamically modified to include the host name through which the site is accessed. This means that if you have three different bindings, you will have three different cache keys (assuming no other varying parameters).

    Here’s how to modify your Controller Action:

    [MyOutputCache(VaryByParam = "None", VaryByCustom = "Host", Duration = 7200)]
    public ActionResult Index()
    {
        // ...
        return View();
    }
    

    Notice the inclusion of VaryByCustom = "Host", which is then seen by your overriden OutputCacheAttribute’s GetVaryByCustomString() method and thus included in the cache key that is used.

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

Sidebar

Related Questions

My question is concerned about group of settings that can be found within development
I have a question about the following code: public Class Settings{ public static final
i have a question about Post-Builds. We have a Post-Build in project settings. This
I have a question about MS SQL Server string-to-datetime implicit conversion. Specifically, can I
I have the question about Properties.Settings.Default generation. By default there are only defaultInstance is
I have a question about my haproxy config: #--------------------------------------------------------------------- # Global settings #--------------------------------------------------------------------- global
I have a question about logging settings in the supervisord.conf file. Our server at
This is a question about setting our website's Language and Culture settings with regards
I have a question about ThreadStart delegates in vb.net. I am taking over a
I have a question about netbeans. I made a new netbeans php project, configured

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.