Cache and optimize checksum calculations

- for non template strings, checksum and contentsum are same, so let's
  calculate them once
- cache both values for further reuse