I'm looking for a way to run some slow code after after the page is rendered to the user. Concretely, I'd like to be able to do something like this:
get '/fast-action' do
compute_after_render { put some slow code here }
'request successful'
end
I thought about inserting the information about the computation into the database.
And then running something like rufus scheduler that would be checking if there is something to compute once a minute.
But I wouldn't want the user to wait for the database to complete the insertion.
Is there any way to make Sinatra run some code after after the page is rendered to the user?