I have a few elements on my site that when clicked, generates content on the site using javascript, however, when the user navigates to another page on my site, and then goes back to the previous page, the content that was generated using javascript gets erased/reset. Some things are cached in the browser, such as user input on input-fields, checkboxes and so on, they remain cached, but content that was generated using javascript gets erased.
How can I cache the content that was generated using javascript, so it's remembered and restored when the user goes back to the page, similar to how their actions on the input checkboxes are remembered?
Is this possible to do natively? Caching client-side generated content in the browser as it's generated, or is this something I have to cache myself using sessionStorage/localStorage? Thank you in advance!