Chapter 3

Caching

Control when social card images refresh

Sitepress runs on Rails, so all caching techniques from the Rails caching guide apply directly. Use expires_in and fresh_when in your controllers to set HTTP cache headers.

This page covers the Sitepress side. For how OpenGraph+ handles caching at the HTTP level, see the HTTP Caching guide.

Meta tag overrides

If your pages are served statically or you want per-page cache control without a controller, add meta tags to your layout:

<meta property="og:plus:cache:max_age" content="86400">
<meta property="og:plus:cache:etag" content="<%= current_page.data.version || 'v1' %>">

Use frontmatter to set per-page cache versions:

---
title: My Page
version: "rev-3"
---

When the version changes, OpenGraph+ re-renders even if the cache hasn’t expired.

Recommendations

Page type Strategy
Static content pages og:plus:cache:max_age of 604800 (1 week)
Blog posts og:plus:cache:max_age of 86400 (1 day) + etag
Frequently updated Short TTL + etag for instant invalidation