Reports Caching

  • Generating reports is expected to be mainly an IO dominant operation, mainly in executing the query and reading the report file from desk.
  • To improve performance, we may try to cache the compiled report, which is an object of type JasperReport built from the JRXML file.
  • As reports rarely changes, the caching can be for an extended time, from 1 hour to even 1 day.
  • An API for explicitly evicting a certain report from the cache can be useful.
  • Spring boot already provides a powerful API for caching. Supported implementation like ehCache can be configured to have certain size, so, we don't need to worry about memory leaks.
  • But prior to this, it can be useful to do some profiling to check the percentage of request time spent on reading report files, specially on SSD drives, which should be the best case scenario.
  • The cache ID for reports on disk should be their relative path to the reports directory.