I have two archive pages sorted in random order. When I click an item and then hit the back button in the browser, I come back to the same random order. But if I make a search first and then go back and forth, I get a new random order. I would like the random order to stay the same until I reload the page, as it does when I'm not making a search. Thank you!
hidden link
hidden link
The problem here is that when you make a search, it triggers the View to load (new) results.
That will apply all settings of the View to the new sets of results, and hence since you order random, it'll fire the random calculations and that'll result in a different output.
Instead, clicking a single item, and then going back with the browser navigation, is generally getting content cached in the browser (similar as with Forms, where form fields will stay filled until you actually reload a page, even if you "navigated back" to that form from somewhere else).
I fear there is no solution to that, this is how the process works (or, we could say, how browsers work).
Please let me know if I misunderstood the issue?
"Instead, clicking a single item, and then going back with the browser navigation, is generally getting content cached in the browser". Yes, this is what I expected, but instead, the page reloads. That I get a new random order when I make a new search is expected.
Why does a reload fire when going back? Why isn't the page cached in the browser? I haven't experienced this on other sites on the net.
Here you mentioned it gives no new random order:
https://toolset.com/forums/topic/new-random-order-when-using-browser-back-button/#post-1509107
>When I click an item and then hit the back button in the browser, I come back to the same random order.
I tested on your site, and on a closer look I think the issue is as follows:
1. When loading hidden link, or hidden link, no random order is applied. We can reload as many times we want, nothing changes.
2. If now we run a search, submit and wait for the new results, and then reload that page many times, each time the order changes. Random is applied.
That is certainly unexpected.
Can I have a look at this from the backend?
I'll maybe need to make some small changes to the View if this is ok.
Now it works.
When I load the page, it re-orders by random.
This did not work before.
Something that you disabled or changed must have made it work.
The plugins, or Theme, that you changed/disabled, or the Code or else would be the cause.
Re-enabling it should bring back the issue.
If you can confirm this, please can you add all details such as Email of the author, plugin/theme name and version, and a copy of it, so I can then test and confirm the issue, in order to eventually cooperate with the third party to fix this issue?
Thanks!
Hi Beda,
I don't know if I'm unclear or if you are asking something I don't get, but here is how I see it:
1. Yes, reordering the random item by reloading the page has always worked and it should be like that. A new random order for each reloading.
2. When I make no search, just accept the random order and go back and forth between listing and item with the back button in the browser; before the random order stayed, it does not now. I'm sure this has to do with that I turned off Hummingbird's caching (WPMUDEV plugin).
3. When I make a search and go back and forth between items and search page with the back button in the browser, I get a new random order, both now and before.
I want the random order to stay and not get triggered by moving back and forth between listing and item. I want the listing to be cached in the browser, not reloaded.
I understand you can confirm that the cache plugin you mention interrupted one of the reload processes, which should be a known issue:
https://toolset.com/documentation/user-guides/views/front-page-filters/how-to-use-views-parametric-search-on-large-sites/
Views will turn off its own cache if random is used, but other cache systems will not know that.
Hence, the cache should then be turned off in those systems, accordingly, to leave the pages where random views live "free" from the cache.
This should then result in the order applied always, and that should be seen as the expected behaviour.
Related to the other issue, when visiting that page and performing a search, then navigating back, does work differently than I see it working locally, I see what you mean now.
I actually see Locally, the random will NOT be triggered by a simple browser-back navigation.
It does, however, on your example provided online.
I had a very similar issue 4 years back here hidden link
Also a colleague, here: hidden link
We found this was due to the way browsers handle cache and settings in the Views and some workarounds where provided.
See hidden link and the ticket here hidden link
I suspect this is a similar if not the same issue.
Can you confirm this?