Refactor calculation of refresh time and cache time

- Move duration_seconds (graph time period) calculation up to before the
calculation of the refresh time and cache values.

- If the aggressiveness value was set, verify that it falls within the
range of 0-1000.

- If the aggressiveness value > 0, then we need to calculate the refresh
time interval, and adjust the cache setting, then generate the
Javascript attached to the image.