Caching & Cache Invalidation

Edge and client caching tiers, cache buster parameter v, and social platform crawler caching behavior.

The Open Graph Image Generator implements a multi-tiered caching architecture designed to deliver sub-20ms response times for social media crawlers and end users while keeping edge rendering costs low.


Two-Tier Cache Architecture

Every successfully rendered PNG image is served with standard HTTP cache headers:

HTTP/1.1 200 OK
Content-Type: image/png
Cache-Control: public, max-age=86400, s-maxage=604800, stale-while-revalidate=86400
ETag: W/"1a2b3c4d5e6f..."
cf-cache-status: HIT

1. Browser / Client Cache (max-age=86400)

  • Duration: 24 hours (86,400 seconds).
  • Browsers and RSS readers store the image locally and will not issue network requests for the same image URL within this window.

2. Edge / CDN Cache (s-maxage=604800)

  • Duration: 7 days (604,800 seconds).
  • Cloudflare edge data centers worldwide store the generated PNG. Any subsequent request from crawlers or users in the same geographical region is served directly from edge memory in under 20ms.
  • Stale-While-Revalidate (86400): If a request arrives after 7 days, the edge serves the cached copy instantly while asynchronously generating a fresh copy in the background.

The Cache Buster (v) Parameter

Because URLs are deterministic and cached for 7 days at the edge, modifying the title, theme, or author in your CMS or database will not alter the cached image if the generated URL remains identical.

To force an immediate, fresh render, pass the v parameter with a new value whenever content changes:

<!-- Original Image -->
<meta property="og:image" content="https://api.generativeog.in/v1/images/article.png?title=Hello+World&amp;v=1" />

<!-- Updated Content: Incremented Version -->
<meta property="og:image" content="https://api.generativeog.in/v1/images/article.png?title=Hello+World+Updated&amp;v=2" />
  1. Content Updated Timestamp: Use the Unix timestamp of when the article or page was last edited (e.g. v=1734567890).
  2. Commit SHA / Version Tag: Use your deployment commit SHA (e.g. v=a1b2c3d).
  3. Monotonic Counter: Increment an integer version in your database schema whenever the title or metadata changes (v=1, v=2, etc.).

Social Platform Crawler Caching Quirks

A frequent source of confusion is that social media crawlers (Facebook, LinkedIn, Twitter/X, Slack) do not follow normal HTTP expiration rules:

  • Aggressive Crawler Caching: Even if your CDN cache expires or is purged, platforms like Facebook and LinkedIn retain scraped metadata and card images in their internal caches for several days or weeks.
  • Crawler Recrawl Limitations: If you simply update the image at the same URL, social platforms may never re-fetch it because their scraper assumes the content at that URL is immutable.

The Correct Invalidation Procedure:

  1. Update the og:image URL in your HTML: Add or increment v (e.g., &v=3) in your <meta property="og:image"> tag.
  2. Deploy your page: Ensure the HTML served at your public URL contains the updated tag.
  3. Trigger Platform Re-scraping via Debuggers:
    • Facebook: Open the Facebook Sharing Debugger, input your page URL, and click Scrape Again.
    • LinkedIn: Open the LinkedIn Post Inspector, enter your URL, and click Inspect.
    • Twitter / X: Post the link in a private tweet or test draft; Twitter re-evaluates images when a new image URL is detected in the card metadata.

To inspect how social crawlers see your page tags right now, run your URL through our Page Inspector.