Cache Clear and Auto-Refresh List Page in Custom Script

I am using select2 library for multi-select and on click of a button I am iterating all the selected values and pushing it to a field one by one using method “frappe.client.insert” and I’m able to do so successfully.
Also what I’m doing is on click of that button, I am redirecting to main list page of that doctype. But what I noticed here is sometimes on redirection to List Page, it automatically refreshes and sometimes it don’t. What I want is on redirection is it refreshes automatically.

Along with that, I’m also having cache issue. After redirection and refresh(on click of refresh button on main page), and then clicking “NEW” the values i selected last time using select2 library is auto selected and same is happening untill and unless I clear cache of browser.
So also want to clear the cache at time of redirection using custom script or any alternate way(js or jquery).

Any help or suggestion will be appreciated.

Thank You

Any way for cache clearing via custom script ??

Still looking for an answer

Try this

i am using datatable actually and many times it doesn’t gets loaded on click of new untill i refresh the page.
So I thought of clearing the cache on page load but frappe.ui.toolbar.clear_cache() is clearing cache in an infinite loop. Any way to perform the same just for 1 time ?

or any other way to solve the issue of datatable on page load bcoz I’m using onload triggerfor the datatable

I’m assuming the problem is, your event click worked only first time. Am i right?

No I want it to work only for one time, on page load so that the datatable gets loaded

I got it. You want to redirect to list page and refresh.
Can you show me how you redirect to main list page?

frappe.set_route("List", "Other Recommendation");

frappe.ui.form.on("Other Recommendation", {
	refresh: function(frm) {

Currently using this to refresh and routing.

I have a dirty solution which refresh all the time when you set_route to list but you always have warning message in console.
try this and let me know if it works. I’ve tried, it worked:
frappe.set_route("List", "Other Recommendation",{"":""});