1

Google suggests to retrieve the base url again when needed after 60 minutes after the origin query because the url's expire. So far, so good. But what if I'm developing a photo gallery and I'm displaying 5000 or them in a grid? Should I query the API again and again? They use a maximum page size of 100 (instead pf 1000 for google drive), so we're starting many requests if that's true. I'm already caching the photos locally, but when the user scrolls to another section, the url will be expired after one hour.

What is the best solution for that?

Denny Weinberg
  • 2,492
  • 1
  • 21
  • 34
  • Because [thumbnails](https://developers.google.com/drive/api/v3/file#uploading_thumbnails) are invalidated each time the content of the file changes, it is important to upload new thumbnails each time the content is modified. Metadata changes do not invalidate thumbnails. – Jessica Rodriguez Jun 10 '19 at 14:49
  • That isn't a useful information for me. All the photos are of course not modified permanently. – Denny Weinberg Jun 10 '19 at 15:32
  • I'm sorry of this is not helpful. – Jessica Rodriguez Jun 10 '19 at 16:21

1 Answers1

1

Google has a batch request for that use case : https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchGet

Anyway the maximum number of items you can request per call is 50, so you should anyway queue some of those requests.

Personally I made it automatic in my code. When the baseUrl i'm loading gives me a 403, it automatically get the mediaitem updated object and retry.

Also you should not cache base urls or generally mediaobjects within different app launches (assuming you're writing an app). You should retain only the mediaItem id and reload it or the entire collection when needed.

Axy
  • 374
  • 2
  • 15