moved metric gathering before caching, and conditional on most recent timeperiod
starting to work on HTML formatting