Caching Information

Applications using the Zenfolio API can decrease the amount of information passed on the network and improve response times by caching information returned by loader methods. To determine whether object information has changed and needs to be reloaded, applications can use several change number fields provided in various snapshots:

  • The HierarchyCn field of the User snapshot facilitates caching of the user's group hierarchy. This field is incremented each time user's group hierarchy is changed. An application can save the entire response of LoadGroupHierarchy and this number in its cache. If in a subsequent session the application determines that the hierarchy change number has not changed, there is no need to call LoadGroupHierarchy again and the cached version can be used.
  • The TextCn field of the Photo snapshot facilitates caching of photo caption, keywords, categories, and copyright. This number is incremented each time one of these fields changes. Typically, an application would call the LoadPhotoSet or LoadPhotoSetPhotos method to obtain a list of photos in a gallery. These methods return the TextCn field of each photo but do not return any caption, keywords, or categories. The application would match photo text change numbers to the information in its cache and only load captions for those photos which captions have changed with individual calls to LoadPhoto.
  • The TextCn field of the PhotoSet snapshot facilitates caching of photoset caption, keywords, and categories. This number is incremented each time one of these field changes. The TextCn field of the Group snapshot facilitates caching of the group caption. This number is incremented each time the group caption changes.

    Similarly to photos, photosets and groups loaded by LoadGroup and LoadGroupHierarchy methods have their TextCn fields loaded but not the actual captions. An application can use the values of the TextCn field to determine if a cached caption (as well as categories and keywords for photosets) can be used.