Cache mechanism for boxes

See #1357 and #1367