Answer the question
In order to leave comments, you need to log in
How to save the state of the HTML page / data on it, so that you can return to it?
I formulated the question in a strange way ... But in general, there is a page with random publications, when you go to one of these publications and then press the "back" button, the initial page is updated. It is necessary that it be preserved in the state when the user only followed the link to the publication. Here.
While the option with pushState comes to mind, but maybe there is something better, mb using php?
PS The page has infinite scrolling of publications.
Answer the question
In order to leave comments, you need to log in
1. Make a snapshot when requesting a page: IP+UserAgent/Cookies => URL+[structure: ID's of publications + something else that a specific URL or its "mask" needs]
2. When requesting again, we take the state from this table and we restore.
The implementation of storage and loading can be done both on the server and on the client.
As a fronter - I will describe how I would implement it on the client. If the pages are dynamic - saved all the necessary component states in the redux / vuex component state store - depending on what kind of framework. If it's static, you could use localStorage. States can be pushed there. Although the structure of local storage is quite primitive - a key and a value, but no one forbids pushing serialized json into a value
It is necessary that it be preserved in the state when the user only followed the link to the publication.Switch to a new window (tab).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question