perf: cache link previews for 10 minutes (#32161)

Often used for masters and often never change
This commit is contained in:
Ankush Menat 2025-04-16 14:41:33 +05:30 committed by GitHub
parent e038da5129
commit 599c3a9b77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View file

@ -1,8 +1,10 @@
import frappe
from frappe.model import no_value_fields, table_fields
from frappe.utils.caching import http_cache
@frappe.whitelist()
@http_cache(max_age=60 * 10)
def get_preview_data(doctype, docname):
preview_fields = []
meta = frappe.get_meta(doctype)

View file

@ -131,10 +131,15 @@ frappe.ui.LinkPreview = class {
}
get_preview_data() {
return frappe.xcall("frappe.desk.link_preview.get_preview_data", {
doctype: this.doctype,
docname: this.name,
});
return frappe.xcall(
"frappe.desk.link_preview.get_preview_data",
{
doctype: this.doctype,
docname: this.name,
},
"GET",
{ cache: true }
);
}
init_preview_popover(preview_data) {