diff --git a/frappe/client.py b/frappe/client.py index f3d56067f8..591ef09631 100644 --- a/frappe/client.py +++ b/frappe/client.py @@ -427,7 +427,11 @@ def validate_link(doctype: str, docname: str, fields=None): values.name = frappe.db.get_value(doctype, docname, cache=True) fields = frappe.parse_json(fields) - if not values.name or not fields: + if not values.name: + return values + + if not fields: + frappe.local.response_headers.set("Cache-Control", "private,max-age=1800,stale-while-revalidate=7200") return values try: diff --git a/frappe/public/js/frappe/form/controls/link.js b/frappe/public/js/frappe/form/controls/link.js index 5b59e09ee2..dea3afd659 100644 --- a/frappe/public/js/frappe/form/controls/link.js +++ b/frappe/public/js/frappe/form/controls/link.js @@ -685,11 +685,16 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat // to avoid unnecessary request if (value) { return frappe - .xcall("frappe.client.validate_link", { - doctype: options, - docname: value, - fields: columns_to_fetch, - }) + .xcall( + "frappe.client.validate_link", + { + doctype: options, + docname: value, + fields: columns_to_fetch, + }, + "GET", + { cache: !columns_to_fetch.length } + ) .then((response) => { if (!this.docname || !columns_to_fetch.length) { return response.name;