Autogenerating module list in OnDemand interactive apps

In an effort to be more flexible with supporting available versions of programs, I wrote a small piece of Ruby code into each interactive app to list all the available versions of the program the interactive app runs, as (in form.yml.erb):
app_name = “Abaqus”
mod_name = “abaqus”
template_root = “/var/www/ood/apps/templates/”
modulecmd = template_root + ‘’ + " " + mod_name
modules = %x[ #{modulecmd}]
widget: select
label: <%= app_name %> version
help: “This defines the version of <%= app_name %> you want to load.”
<% modules.lines.reverse.each do |line| %>
<% unless line.to_s.strip == “” %>
- [ “<%= line.split(’/’)[1] %>”, “<%= line %>” ]
<% end %>
<% end %>

where the “” script needs to source our Lmod (because Lmod does not get set up automatically in non-interactive shell) and then run the module spider command:
source /uufs/
module -t spider $1 2>&1

This generates the list of modules, e.g. like:
- [ “2016”, “abaqus/2016” ]
- [ “2019”, “abaqus/2019” ]
- [ “2021”, “abaqus/2021” ]

This works fairly well except that I have noticed a huge slowdown of the OnDemand server responsiveness when I have more than a handful of interactive apps like this. From looking at the server load, it appears to me that the module command is being called a lot every time a webpage is being refreshed, even when that page does not do anything at all with the interactive apps. This makes things so slow that the OOD server is very hard to use.

Does Ondemand regenerate the form.yml files for all the apps whenever any OOD webpage refreshes? If it does, any way to reduce this so e.g. only whenever the given interactive app page needs to be shown the form.yml.erb is processed?

Or any other thoughts in this regard?