Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Disable "Read" Request Cache In Kendo UI Data Source

I'm using ASP.NET MVC Wrapper in MVC4 application.

Everything works fine besides one specific issue: I defined a datasource for Kendo UI Grid, and when the view loads, the read action is being called as expected.

However, when the page reloads, "read" request gets a response with 304 result.

How can I disable the cache through data source configuration?

like image 759
ZENIT Avatar asked Feb 20 '13 08:02

ZENIT


3 Answers

You are able to set the 'cache' attribute in your Kendo dataSource to false, which apparently (NOTE: I have not tested this) will force the requested page(s) to be newly fetched on every request.

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

Note too that you can specify cache behavior per Kendo transport operation (ie, it can be at the level of CRUD operations or for the whole transport).

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

Code:

transport: {
    read: {
        cache: false
    }
}
like image 121
dpb Avatar answered Oct 15 '22 19:10

dpb


.Read(read => read
    .Action("Action", "Controller", new { area = "Area" })
    .Type(HttpVerbs.Post))
like image 37
user2162986 Avatar answered Oct 15 '22 20:10

user2162986


You can try decorating on server side controller's action that loads view with

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

attribute, for instance

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 secondary storage of sensitive information Duration - The time, in seconds, that the page or user control is cached. Setting this attribute on a page or user control establishes an expiration policy for HTTP responses from the object and will automatically cache the page or user control output.

like image 5
Vlad Bezden Avatar answered Oct 15 '22 19:10

Vlad Bezden