DEMO

XASG - iNAV
at -- --- ----, --:--:-- --
A $-.--

Fund iNAV Refresh

This is a demo of how to update the iNav data on a page using a simple API from a NodeJS web server, and jQuery.

This demo consists of the following components:

  • A NodeJS web server acting as an API endpoint
  • jQuery function that runs every second making a call to the API endpoint to refresh the values

Nodejs web server

The NodeJS web server is acting as an intermediary for the IHS API. It has a background process to constantly request the fund data from IHS and store this in it's local cache, as to follow the restrictions of the IHS API, and this cached data is then served when requested.

Caching Strategies

IHS API Key

An IHS API key is generated when the web server starts up. This key is then stored in the local cache with a Time to Live (TTL) of 3500 seconds (~58 minutes). A scheduled task is also created to refresh this key every 55 minutes.

Fund Data

The fund data of select Fund tickers are retrieved at startup, after an API key has been generated. This key is then stored in the local cache with a Time to Live (TTL) of 2 seconds. A scheduled task for each fund ticker is also created to refresh this fund data every 1 second.

Having this 1 second overlap in the cached fund data's TTL allows the web server to always have a cached value to respond with to any request, even ones that are sent between the 1 second refresh window, allowing speedy response times.