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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:16:25+00:00 2026-06-10T02:16:25+00:00

I’m having trouble using the OutputCache attribute in Microsoft’s MVC3 framework. Please imagine the

  • 0

I’m having trouble using the OutputCache attribute in Microsoft’s MVC3 framework.

Please imagine the following controller action, which can be used as part of an AJAX call to get a list of products based on a particular manufacturerId:

public JsonResult GetProducts(long manufacturerId)
{
    return Json(this.CreateProductList(manufacturerId), JsonRequestBehavior.AllowGet);
}

I want this result to be cached on the server to avoid making excessive database queries. I can achieve this by configuring the attribute thus:

[OutputCache(Duration = 3600, Location = OutputCacheLocation.Server, VaryByParam = "manufacturerId")]

This works as I expected – the browser makes an intitial request which causes the server to create and cache the result, subsequent requests from the same or different browser get the cached version.

But… I also want the browser to cache these results locally; if I filter first on manufacturer X, then Y then go back to X, I don’t want it to make another request for X’s products – I want it to just use its cached version.

I can make this happen, by changing the OutputCache to this:

[OutputCache(Duration = 3600, Location = OutputCacheLocation.Client)]

Here’s the question: how do I combine these so that I can have both sets of behaviour? I tried setting the Location to ServerAndClient but this just made it behave the same as when Location was Server.

I’m sure that the problem has something to do with the “Vary: *” response header I get with ServerAndClient but I don’t know how to get rid of it.

I welcome comments about the rationality of my intentions – the fact that I’m not getting the results I expect makes me think I might have some fundamental misunderstanding somewhere…

Many thanks.

PS: This is on a local dev environment, IIS Express from VS2010.

  • 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-10T02:16:26+00:00Added an answer on June 10, 2026 at 2:16 am

    You can use OutputCacheLocation.Any which specifies

    The output cache can be located on the browser client (where the
    request originated), on a proxy server (or any other server)
    participating in the request, or on the server where the request was
    processed. This value corresponds to the HttpCacheability.Public
    enumeration value.

    You may want to also set Cache-control public to in the HTTP header for these requests.

    Edit

    It seems, depending on your .Net version of the web server you may need to include Response.Cache.SetOmitVaryStar(true); within your controller action to remove the Vary * headers as you suggest.

    Details of the reason why in .Net 4 breaking changes release notes.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words

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.