I know that I can store the last element on the page and when an user returns I can use an offset to fetch the content from where that user has left off, my question is, is there a way to keep the page loaded with all the dynamic content?
For example on LinkedIn or Twitter, when you go back from a tweet/post the page does not seem to make the requests again, it's an instant transition.
Does that mean you can preserve the entire page with JS somehow and restore it immediately without making requests to the server again ? Or is it some sort of shenanigan where the page does not actually change, so it's just one page app, and all the content gets loaded dynamically ?
Edit: I think Twitter/LinkedIn somehow replaces content on the same page and does not redirect to another page (I'm guessing), But I have 2 separate page.
I will rephrase, and try to explain better.
I have a Infinite scroll page, that loads content in chunks, say I load 10 images at a time staked vertically.
Users scrolls and loads 30 pictures, when you click on a picture you get redirected on another page where you see the picture full screen.
Now users clicks the back button, gets back on the main page, how can I make so the users sees the content from where he left off.
Solutions I've tried.
1 -- I can store the current offset of an image and load from there when the user get's back, but I only load 10 images at a time, if the user click the 11-nth picture, I can still pull from there but it messes with the scroll position because that picture is now first on the page, and the page is scrolled down, to where the 11-nth picture would have been.
2 -- I can store how many pictures have been loaded, so if the user loaded 50 pictures while scrolling when, he gets back and I just load how many pictures there were before the page change, but I think that's not a good idea because loading big amounts of content like that impacts performance.
How Can I show the user the content from where he left of, when returning to the main page, and keeping the scroll position on an infinite scroll page? (I'll give twitter as an example again)