Frappe context not changing. Cache problem

Hi. I am having an issue with context in templates.
I have website generator with function get_context

def get_context(self, context):
        context.no_cache = True
        context = {
            "text": self.text,
            "assigned_to": self.assigned_to,

It was working normally, but in some point context stoped to update. Even if I deleting get_context function my template still the same with previous values.

Unfortunately i didn’t find docs for this problem.

What I already tried:

  • context.no_cache = True

  • bench --site all clear-website-cache

  • bench --site mysite clear-website-cache

  • bench clear-website-cache

  • bench --site mysite clear-cache

  • bench clear-cache

No luck. Any suggestions?

Frappe version v12.x.x-develop () (develop)

1 Like

Did you find any solution for this? I am facing the same issue.

Hey, did you find its solution? Same problem here (Oct, 2021) :frowning:

can you once try putting no_cache = 1 in the global scope where your get_context function lives?
I’ve seen that across frappe codebase so i think it might work (?)

1 Like

Is there anyone who found solution for this issue?

Try this

#bench restart
#sudo supervisorctl restart all

either will clear all cache

Thank you for the reply. I am using ERPNext in production. after running this command => sudo supervisorctl restart all it is working fine now

fyi i tried to clear all the cache but it didn’t solve the problem

Glad to help, with the command there are two version

  1. sudo service supervisord restart

  2. sudo supervisorctl restart all

Try either one of those two

For me , this solved my issue.


def get_context(context):
    param  = frappe.request.environ.get('QUERY_STRING')
    asset_code = param.split("=")[1].replace("%20"," ")
    query = f""" ....  """
    asset_table = frappe.db.sql(query, as_dict=True)
    context.no_cache = 1 # <--- this line 
    context.asset_table = asset_table
    return context
1 Like