naver / egjs-persist

Provide cache interface to handle persisted data among history navigation.
https://naver.github.io/egjs-persist/
MIT License
42 stars 10 forks source link

Use document.referrer as a key on history management. #36

Open jongmoon opened 5 years ago

jongmoon commented 5 years ago

Currently only URL is used as a key for different page. and URL is added on depths arrays. But It has some problem. it could have too many duplication of URL. So it removes previous URL and just adds new depth. For example,

Then history will be B -> C -> D -> A and it make problem when you go back to previous A and navigates to other sites. For example, A-> E... In this situation B-> C->D should be removed. But depth of A (5) is bigger than B, C, D(2, 3, 4).

To supplement this, we can use document.referrer with URL. It makes possible that A(1) followed by none can be distinguished by A(5) followed by D(4).

For example,

And also it could manage history more correctly. For example if persist is not applied on page A, and You navigate like follows you could make depths unintended way.

Then B -> C is the depths of this history. But If you add A (referrer) on a history then you can acquire depth like A->C as you intended.