This is a migrated thread and some comments may be shown as answers.

prevent ajax caching on .read()

13 Answers 796 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
David A.
Top achievements
Rank 1
David A. asked on 16 Aug 2012, 04:21 AM
Hi,
I am using the MVC helpers and ran into a problem with json data caching in ie.  I don't see a way to set caching = false with the fluent DropDownList helper.  Am I missing something with this?

My workaround is to tag my json methods with the following (courtesy of Zack at http://www.kendoui.com/forums/framework/data-source/read-without-cache.aspx)

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]

David A

13 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 20 Aug 2012, 01:46 PM
Hello David,

 
In general you cannot disable the cache through the fluent interface. Nevertheless it is sufficient to set the ServerFiltering to true in order to achieve your goal:

.DataSource(source => {
              source.Read(read =>
              {
                  read.Action("GetCascadeProducts", "ComboBox")
                      .Data("filterProducts");
              })
              .ServerFiltering(true);
          })
Check the CascadingDropDownList demo. Let me know if I am missing something.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bubuy
Top achievements
Rank 1
answered on 11 Sep 2012, 03:57 PM
I am also running into the same problem.  I have cascading dropdownlist on kendo grid's popup editor.  I have tried both suggestions and it is still not working.  the caching problem happens when you switch from edit mode to create or vice-versa.
0
Georgi Krustev
Telerik team
answered on 12 Sep 2012, 10:06 AM
Hello Arnold,

I answered the support ticket opened on the same subject. I will ask you to continue our conversation there in order to avoid any duplications. 

Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
michel
Top achievements
Rank 1
answered on 27 May 2013, 12:10 PM
Running into the same problem, but we don't want to change to ServerFiltering.
Disable of cache on Controller level does not fix the problem.

Any ideas to force the control to refresh it's items ?
0
Justin
Top achievements
Rank 1
answered on 30 May 2013, 01:46 AM
You actually can prevent caching from the fluent interface. You just need to set the type to 'Post' for your read action.  ie -

.DataSource(source =>
 {
           source.Read(read =>
                   {
                           read.Action("ActionMethod", "Controller").Type(HttpVerbs.Post);
                    });
})
0
michel
Top achievements
Rank 1
answered on 31 May 2013, 01:13 PM
Thanks, works like a charm.
0
MarkSci
Top achievements
Rank 1
answered on 30 Sep 2013, 01:11 PM
This really helped me too Justin, thanks!
0
Robert
Top achievements
Rank 1
answered on 04 Dec 2013, 02:26 PM
I realise this is an old thread, but as Kendo is built on jquery, you can switch off caching across the board by having this snippit either in a master page, or just on the pages that you want to disable caching on:
$.ajaxSetup ({
   // Disable caching of AJAX responses
   cache: false
});
0
Jon
Top achievements
Rank 1
answered on 10 Dec 2013, 06:55 PM
Justin,

Your buried fix was exactly what I have been digging for also. Thanks!
0
Dan
Top achievements
Rank 1
answered on 24 Jun 2015, 06:54 PM

ServerFiltering requires an actual filter.
Justin and Robert have working solution for non cascading DropDown 

 

0
Jon
Top achievements
Rank 1
answered on 03 Feb 2020, 09:30 PM

The only way I have been able to solve this issue is to set the global ajax setup to have cache set to false.

Place this in your layout or a global js file

$(function () {

   $.ajaxSetup({
        cache:false,
    });

}

 

This will disable caching for all ajax calls

0
Kiran
Top achievements
Rank 1
Veteran
answered on 24 May 2020, 10:44 PM
Thank you David, It is working exactly
0
Kiran
Top achievements
Rank 1
Veteran
answered on 24 May 2020, 10:46 PM
Thank you Justin, nice tweak and it is also working :)     
Tags
DropDownList
Asked by
David A.
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Bubuy
Top achievements
Rank 1
michel
Top achievements
Rank 1
Justin
Top achievements
Rank 1
MarkSci
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Kiran
Top achievements
Rank 1
Veteran
Share this question
or