Forced material refreshing before render
I didn't figure out how to automatically click that button, so tried to cut/create link between Output and previous node.

This code is kind of refreshes material named "Material" before rendering (at least my case).

import bpy
def remove_link(scene):
   mat = bpy.data.materials['Material'].node_tree
   node1 = mat.nodes['Mix']
   node2 = mat.nodes['Output']
   links = mat.links
   link = node1.outputs[0].links[0]
   links.remove(link)
   link = links.new(node1.outputs[0], node2.inputs[0])

bpy.app.handlers.frame_change_pre.append(remove_link)