I have asked this question before and I got two answers:
Quote from Stefan Arentz:
There is no easy answer here. The WKWebView cannot be archived and it does also not participate in UI state preservation/restoration. You already discovered this.
For Firefox for iOS we took a different route to work around these limitations. This far from ideal but it does work.
When we restore a tab that has session info (previously visited pages) attached, we load a special html page from a local web server (running on localhost) that modifies the push state of the page and pushes previously visited URLs on the history stack.
Because these URLs need to be of same origin, we basically push urls like `http://localhost:1234/history/item?url=http://original.url.com
In our UI we translate this to display original.url.com. When the user goes back in history to load these, we intercept and instead of loading the page from localhost, we load the original page.
It is a big hack but that is all we have at this point.
Problem is, I downloaded the Firefox app for iOS and tested whether it restores a tab or not. I found out that after you close the app and re-open it all is lost. The option to go back isn't there.
This is a big deal for me and the web browser that I'm building. So, I'm hoping for a third answer, a better solution. I do feel optimistic because more than a year has passed.
Going back to using UIWebView isn't an option because of poor performance.