Refresh Page with Script

HI all, I’m working on a pretty large custom page and needed to refresh quite a lot, small changes like usual but having to wait until the page refreshes is a bit of a pain. Wondering if anyone knows how to use JS to refresh the page.

I’ve tried

delete locals.Page['page-name']
frappe.views.pageview.show('page-name')

and it sends a frappe.call request to

frappe.desk.desk_page.getpage

which returns the updated content, which is awesome, but just doesn’t run it. Seems to run the already downloaded version, anyone have any ideas?

Update for others, I’ve figured out how to refresh the JS, just not the template.

If you want to refresh your JS do the following:

delete locals.Page['page-name']
delete frappe.pages['page-name']
frappe.views.pageview.show('page-name')

Unfortunately that won’t update the displayed page, the frappe.templates object is updated however it just doesn’t run refreshing the displayed content.

GOT IT!!!

Apparently the templates themselves are cached, both in the form they are received by the pageview request, and the compiled versions of themselves.

I can verify this works for me!!! Good luck everyone!

var pagename = 'xxxx', template_name = 'xxxx'
delete locals.Page[pagename]
delete frappe.pages[pagename]
delete frappe.templates[template_name]
delete frappe.template.debug[template_name]
delete frappe.template.compiled[template_name]
frappe.views.pageview.show(pagename)

This has saved me a lot of time waiting for page refreshes already, rather than waiting 20 seconds each time, it now runs in about 1 second.

1 Like

Hey Mark, this problem is not unique to pages, it also happens in regular doctypes too.
What (business case) is causing you to need to refresh so often? There may be a better way to do it.

Purely for development purposes, no end users will need to refresh as often. Thanks for taking an interest!