OpenGraph+ reads HTTP cache headers from your pages to decide when to re-render social card images. Middleman generates static files, so cache headers are set by your hosting provider.
This page covers the Middleman side. For how OpenGraph+ handles caching at the HTTP level, see the HTTP Caching guide.
Netlify
Create a _headers file in your source/ directory:
# source/_headers
/*
Cache-Control: public, max-age=604800
Or use netlify.toml:
[[headers]]
for = "/*"
[headers.values]
Cache-Control = "public, max-age=604800"
Vercel
Add headers to your vercel.json:
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Cache-Control", "value": "public, max-age=604800" }
]
}
]
}
Cloudflare Pages
Create a _headers file in your source/ directory:
# source/_headers
/*
Cache-Control: public, max-age=604800
Meta tag overrides
Always available regardless of hosting provider. Add these to your layout’s <head>:
<meta property="og:plus:cache:max_age" content="86400">
<meta property="og:plus:cache:etag" content="<%= current_page.data.version || 'v1' %>">
When the etag changes, OpenGraph+ re-renders even if the cache hasn’t expired. Using current_page.data.version lets you control cache invalidation from frontmatter:
# In your page's frontmatter
---
title: My Page
version: "rev-5"
---
See the HTTP Caching guide for the full reference on cache headers and meta tag overrides.
Purging
Force an immediate re-render from the OpenGraph+ dashboard by purging the cached image for any URL.
Recommendations
| Page type | Strategy |
|---|---|
| Static pages | Long TTL via hosting headers (7 days) |
| Blog posts | Medium TTL (1 day) + etag meta tag |
| Frequently updated | Short TTL + etag for instant invalidation |