Randomized JSON puzzle

Here’s a little puzzle I’m working on. I have a page which lists about 1000 cards, shown in random order. The cards are stored in a collection. That’s a lot for a single page load, so I’m looking to pull them in with JavaScript in batches as a user scrolls the page, via an infinite scroll, until all the posts have been loaded.

The problem is requesting randomly from the JSON endpoint. The only way I can think to solve this is to not actually have the posts show in random order, but have a random starting point, then loop through the collection.

Or, if I can grab the total number of posts in the JavaScript, I can build an array of random numbers and request those from the JSON endpoint somehow. But, returning the data randomly, and having it cached seems tricky.

Anyone else have a thought on how to solve this?

>>>>>>> Unanswered <<<<<<<
4 Replies