OpenGraph.io

Caching

OpenGraph.io caches responses to improve performance and reduce load on target websites. Learn how to control caching behavior for your use case.

How Caching Works

By default, OpenGraph.io caches API responses. When you request data for a URL we've recently fetched, you'll receive the cached result instantly.

  • Cache hits – Return instantly, cost 1 credit
  • Cache misses – Fetch fresh data, cost varies by options used

Cache Parameters

ParameterTypeDefaultDescription
cache_okbooleantrueWhether to allow cached results
max_cache_agenumber-Maximum age of cached data in seconds

Cache Control Examples

Allow cached results (default)

Use cache (fastest)
curl "https://opengraph.io/api/1.1/site/https%3A%2F%2Fgithub.com?app_id=YOUR_APP_ID"

# Equivalent to:
curl "https://opengraph.io/api/1.1/site/https%3A%2F%2Fgithub.com?app_id=YOUR_APP_ID&cache_ok=true"

Force fresh data

Skip cache
curl "https://opengraph.io/api/1.1/site/https%3A%2F%2Fgithub.com?app_id=YOUR_APP_ID&cache_ok=false"

Limit cache age

Max 1 hour old
# Only use cache if less than 1 hour (3600 seconds) old
curl "https://opengraph.io/api/1.1/site/https%3A%2F%2Fgithub.com?app_id=YOUR_APP_ID&max_cache_age=3600"

Tip: Use max_cache_age when you need relatively fresh data but can tolerate some staleness for better performance.

When to Use Each Option

Use cache (cache_ok=true)

  • Building link previews for social sharing
  • Displaying metadata that doesn't change frequently
  • High-traffic applications where speed matters
  • When you want to minimize credits used

Skip cache (cache_ok=false)

  • Monitoring sites for changes
  • Testing your own website's metadata
  • SEO tools that need current data
  • Price monitoring applications

Limit cache age (max_cache_age)

  • News aggregation (data fresh within hours)
  • Content curation with some freshness requirements
  • Balancing performance and data accuracy

Credit Costs

A cache hit costs 1 credit.

Related