Should you save the state in a page with infinite scrolling?

  • I have a page with infinite scrolling on it.
  • I display news in descending order of time and new items keep coming in
  • When people go to the bottom of the page, they load more items automatically and this goes on till my database is not exhausted
  • I also have a search bar at the top of my page letting people search news
  • Here is my concern, user loads page, user scrolls down 4 pages
  • User types something in search box, the 4 pages are completely gone and we have 50 new results instead relevant to the user's search
  • User clears search, now we load 50 default items once again

Should I save the state of the page when user jumps between searches?

  • Example, user loads page, goes down 4 pages
  • User types "Election news" in the search box, default state is stored in local storage with 200 results
  • User searches "UK news" in the search box, election news with 50 items is stored in local storage
  • user clears search box
  • Default 200 items loaded from local storage instantly