art-institute-of-chicago / browser-extension

Browser extension to view a random artwork from our collection in a new browser tab
GNU Affero General Public License v3.0
14 stars 6 forks source link

Add time intervals for more seed collision #37

Closed IllyaMoskvin closed 5 years ago

IllyaMoskvin commented 5 years ago

From prior conversation:

We could make sure that there's more overlap between the results provided to different users. For example, right now, we are using the current timestamp in seconds for the seed. Anyone who launches or refreshes new tab at the same second should see the same image. Something we could consider doing is to sort of... create a scale of time intervals, and choose the biggest one based on when the user last accessed the new tab. (Assuming we can store that in local storage.) For example, let's say that the biggest entry on our scale is a half-hour. If it's been more than 30 min since the last time the user launched new tab, we will take the current timestamp and floor it to the nearest half-hour, and use that as the seed. So if the three of us launched new tab at 10:10, 10:15, and 10:20 AM respectively, and if it's been more than a half-hour since the last time each of us launched new tab, we should all see the same image. Then, let's say that the next entry on our scale is 15 min. If it's been less than a half-hour since you launched new tab, we check if it's also been less than 15 min. If not, we floor the timestamp to the nearest 15 min, and use that as the seed. If yes, we go down to our next smallest interval, say, 10 min. Same deal. Then, down to 5 min, to 1 min, to 30 sec, and etc., until we arrive at our current setting of one second.

This should account for normal usage, as well as cases where users are rapidly refreshing the page to see new images.

IllyaMoskvin commented 5 years ago

On second thought, I'm leaning against this approach for experiential reasons. Per #41, we want users to see artworks that haven't been seen in a while. The approach described in this issue goes against that. Sure, it would ensure that most users get decent performance due to the images having made their way from the local IIIF server into our CDN, but it would also mean that in many cases, users would see the same images as other users each day. Let's avoid that.

Instead, we'll implement the approach described in #42. Each user will be responsible for preloading their own API results and images. That will provide even better performance, since those items will be cached locally, not serverside, and it'll do a much better job of ensuring that each user gets a unique experience.