Service Caching

While reading the API service documentation, you will most likely notice that some of Snaggr's API services allow you to cache their results. Caching the results of your service requests provides a much faster response from Snaggr and has the added benefit of taking some of the load off our poor servers.

The TTL, or time to live, of each service's caching ability will vary from service to service. Some services may have results that don't change as often as others and, therefore, can afford to have longer cache lifetimes. Others, however, may only have a lifetime of a few minutes.

If a service supports caching, you may activate this feature by the adding cache=1 parameter to your POST or GET requests.

Depending on the format you requested, you will notice an extra block of data in the service response payload. Within the top header block of a response there will be an extra section labeled cache.

This section will have 3 values:

  1. created is the time the result cache was created.
  2. expires is the time the cache expires.
  3. id is a unique, 32-character, cache id. Keep note of this string if you wish to manage it with caching API services.

XML

<cache created="2009-12-11 01:05:14" expires="2009-12-11 01:10:14">32f729682254d2401525ca5cbfd0e202</cache>

JSON

"cache":{"created":"2009-12-11 01:06:08","expires":"2009-12-11 01:11:08","id":"87ae3f14b30ee34caa1958b831ade321"}}

PHP

{s:5:"cache";a:3:{s:7:"created";s:19:"2009-12-22 03:32:19";s:7:"expires";s:19:"2009-12-22 03:37:19";s:2:"id";s:32:"d29a8fc0f8563c2b29ffe93fa02f04fa";}}

Take a look at the cache services overview page for more information on how to manage cached data.

Recent Discussions

No discussions yet!