Cache dom before leaving the page, rather than right after loding

This way dynamically added dom (vis js) also gets cached.