How to disable the Read cache request in the Kendo UI data source

I am using ASP.NET MVC Wrapper in an MVC4 application.

Everything works fine, except for one specific problem: I defined a data source for the Kendo UI Grid, and when the view loads, the read action is called as expected.

However, when the page reloads, the read request receives a response with a result of 304.

How to disable cache through data source configuration?

+7
source share
4 answers

You can set the "cache" attribute in your Kendo data source to false, which, obviously (NOTE: I have not tested this), will cause the requested pages to be retrieved again with every request.

Setting the cache to false adds the "_ = [TIMESTAMP]" parameter to the request, which, if necessary, can be analyzed on the server / controller side to avoid cache operations on the server side.

Note also that you can specify cache behavior for a Kendo transport operation (i.e., it can be at the CRUD operation level or for the entire transport).

See here: http://docs.kendoui.com/api/framework/datasource#configuration-transport.read.cache-Boolean

the code:

transport: { read: { cache: false } } 
+12
source

.Read (read => read.Action ("Action", "Controller", new {area = "Area"}). Type (HttpVerbs.Post))

+8
source

You can try to decorate the server side action that loads the view with

 [OutputCache(Duration = 0, NoStore = true)] 

eg

 public class OrdersController : Controller { [httpGet] [OutputCache(NoStore = true, Duration = 0)] public ActionResult Orders(string userId) { // your code return View(viewModel); } } 

NoStore - A Boolean value that determines whether to prevent the secondary storage of confidential information. Duration - the time, in seconds, at which the page or user control is cached. Setting this attribute on the page or user control sets the expiration policy for HTTP responses from the object and automatically caches the output of the page or user.

+3
source

Unable to manage through Datasource configuration. You need to apply the Read method attribute on the controller to prevent caching.

An alternative would be to apply the [HttpPost] attribute to your controller method. Then configure the data source to NOT use the GET method, in which case it will use the default POST method.

0
source

All Articles