Please note that this Support article contains frontend customizations via modifying the legacy Algolia template files, which are deprecated and unsupported by the Algolia Support Team.
For more information, please review this Support article - "Why is modifying Algolia template files for customizations not supported?"
The widget internally caches all loaded hits. By default, it uses its own internal in-memory cache implementation. We provide another implementation which uses sessionStorage, which is more persistent and lets you restore the scroll position when you leave and come back to the search page.
Here is how this would look:
const sessionStorageCache =
instantsearch.createInfiniteHitsSessionStorageCache();
instantsearch.widgets.infiniteHits({
// ...
cache: sessionStorageCache
});
You can find more details on this here: https://www.algolia.com/doc/api-reference/widgets/infinite-hits/js/#widget-param-cache
The sessionStorage should be defined in the same file as the one where infiniteHits widget is defined. In the default theme, the Instant Search widgets are defined in the algolia_instant_search.js.liquid file. But this can also vary if you have defined the widget elsewhere in the code.
Information about Instant Search files for Shopify can be read in the below documentation:
https://www.algolia.com/doc/integration/shopify/building-search-ui/instant-search/?client=ruby#files
Last reviewed 21-04-22.