Fix race condition when templates are recompiled on every request