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

Perform query and load images for future new tabs #42

Closed IllyaMoskvin closed 5 years ago

IllyaMoskvin commented 5 years ago

Currently, we query our API and download images when a new tab is opened. Instead, what we can do is to save our query results for next time in LocalStorage. If a saved query result already exists, we show that data, and query a result for next time. This way, we don't necessarily need to query the API whenever a new tab is opened before displaying stuff.

Likewise, after OpenSeadragon renders all tiles on initial load, we can create a new OSD instance, one that might be hidden using opacity or other tricks. By doing this, we can download some or all of the necessary images into the browser cache. Even if not all of the images are downloaded, we've made progress towards future downloads. Some tiles might have made it into the browser cache, while others might have made it into the IIIF cache, or the CDN cache, if not necessarily into the user's browser.

If we'd like, we can do this preload trick for not just the next new tab, but for some predefined number of them at a time. The longer a new tab is opened, the further ahead we can preload.

IllyaMoskvin commented 5 years ago

This is done. For the most part, it was implemented exactly as described above.

We decided to keep the current design rather than switching to full-screen. With that in mind, we are now using the same image sizes as used by our website. This increases the likelihood of the images having made their way into the CDN. Preloading turned out to be more effective with a pyramid of a few full-sized images, rather than with proper tiles.