How to download/cache files from form.yml.erb

I think you have 2 strategies.

One is you get root or some system user to do this for you, and everyone just reads that shared file. You can setup a crontab to update it on whatever schedule you like.

The second is to do the heavy lifting in an initiailzer. This will execute when the PUN boots up, so it’ll only do the work once when the application is starting up. The downside is that the file will only be populated/refreshed whenever the user logs in. So if you have a more aggressive update schedule (i.e., you need updates every hour) it may not fit (unless you do a lot more work with say a recursive ActiveJob).

Here’s a topic where you can get some inspiration on what such an initializer would look like/do. Be careful with that load File.expand_path('../config.rb', __FILE__) (could actually be require_relative config) though. Rails will recognize every file in that path as an initializer and treat it like a ruby script, and it loads these files in a specific order.