Update database before page display

We have a page that displays info from a database/dataset.
The database gets updated from a Google Calendar via the Google Calendar API.
Currently we are updating our database via the Google Calendar API in response to the OnReady event of the page. This is too late since apparently the page elements have already got the data from the database.
How can we update the database before the database is read by the page?