in Education by
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("" + data + ""); }, 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. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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)]

Related questions

0 votes
    This is our setup: Windows 2003 Server Standard, SQL 2005 and ASP.NET 4.0. We have a news site ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    We are writing a search application that saves the search criteria to session state and executes the search ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    We are writing a search application that saves the search criteria to session state and executes the search ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I have converted a few DropDownLists to jQuery comboboxes to add auto complete functionality etc. however, there ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I have converted a few DropDownLists to jQuery comboboxes to add auto complete functionality etc. however, there ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a viewmodel with an Id property [Required] public int Id { get; set; } But I think this ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I have a viewmodel with an Id property [Required] public int Id { get; set; } But I think this ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I created a brand new Web Application, .NET Full Framework 4.7.2, added Application Insights Snapshot ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    When I select value in select2 multiple selection, the default 0 value is still there in the list. Any ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    Details: We are using Keycloak authentication server with Asp.Net WebAPI. Now I need to get the Keycloak ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    We create new sites in IIS 6 (Windows Server 2003) using IIS Manager. When these sites are created ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    I have user control named DateTimeUC which has two textboxes on its markup: I am dynamically creating this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    I have user control named DateTimeUC which has two textboxes on its markup: I am dynamically creating this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
...