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

  • Home
  • SEARCH
  • 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 6954267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:35:03+00:00 2026-05-27T14:35:03+00:00

I have a simple MVC3 Controller Action like this [HttpGet] [OutputCache(Duration = 1200,Location=System.Web.UI.OutputCacheLocation.Server)] public

  • 0

I have a simple MVC3 Controller Action like this

[HttpGet]
[OutputCache(Duration = 1200,Location=System.Web.UI.OutputCacheLocation.Server)]
public string GetTheDate()
{
    return DateTime.Now.ToString();
}

And I call it from jQuery Ajax like this

jQuery.ajax({
            type: "GET",
            url: "http://localhost:60690/Public/GetTheDate",
            cache: false,
            success: function (data) {
                //alert("success");
                jQuery("#stats").append("<b>" + data + "</b>");
            },
            error: function (req, status, error) { alert("failure"); alert(error + " " + status + " " + req); }
        });

The problem is that the date is always the current date, not the cached response. My understanding was that [OutputCache( Location=Server)] means that the server (the MVC app) caches the response and when the client requests the data, the action is intercepted so as not to bother with DateTime.Now but returns the cached response.

Am I understanding it wrongly or simply doing something wrong?

Update :

3nigma’s answer is right. VaryByParams="none" does the trick but….. It’s obvious from my method that I don’t have any parameters so why should I need to say “none”. Turns out that the ‘Params’ I was thinking the documentation referred to were params in my method are actually not the params in my method, they are anything that the request handler could construe as params.

The MS documentation says

When this property is set to multiple parameters, the output cache
contains a different version of the requested document for each
specified parameter. Possible values include “none”, “*”, and any
valid query string
or POST parameter name.

See the bit in bold (my emphasis) that means that although I’m not expecting any querystring parameters, if any get sent in (like the way jQuery.ajax does when cache:false by appending to the request GET /Public/GetTheDate?_=1324047171837 ) then there is a parameter, whether I expected it or not.

  • 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-27T14:35:04+00:00Added an answer on May 27, 2026 at 2:35 pm

    with cache: false, you are explicitly telling jquery not to cache set cache: true,

    Edit

    set the VaryByParam="none" like

    [OutputCache(Duration=1200, VaryByParam="none",Location=System.Web.UI.OutputCacheLocation.Server)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a simple controller routed as follows: context.MapRoute( Default, {controller}/{action}, new {
How to register Controller in MVC3? I have 2 solutions: MvcApplication (MVC 3 Web
I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I have simple Perl/CGI scripts based web server which is mainly used to display
I have simple from written on C/gtk+ and i have function in this appliction.
With ASP.NET MVC3 (Razor) I have a simple page that loads a jQuery UI
I have a web project using asp.net mvc3. Now clients ask for a security

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.