---
title: "Build Cache · Nuxt OG Image · Nuxt SEO"
canonical_url: "https://nuxtseo.com/docs/og-image/guides/build-cache"
last_updated: "2026-08-16T09:55:30.071Z"
meta:
  description: "Persist prerendered OG images across CI deployments to avoid regenerating unchanged images."
  "og:description": "Persist prerendered OG images across CI deployments to avoid regenerating unchanged images."
  "og:title": "Build Cache · Nuxt OG Image · Nuxt SEO"
---

Nuxt SEO on GitHub

**OG Image v6** is here. Looking for an older version? [~~View v5 docs ~~](https://nuxtseo.com/docs/og-image/v5/getting-started/introduction).

](https://nuxtseo.com/docs/og-image/getting-started/introduction)

](https://nuxtseo.com/docs/og-image/api/define-og-image)

](https://nuxtseo.com/docs/og-image/releases/v6)

Switch to OG Image](https://nuxtseo.com/docs/og-image/getting-started/introduction)Switch to Nuxt SEO](https://nuxtseo.com/docs/nuxt-seo/getting-started/introduction)Switch to Robots](https://nuxtseo.com/docs/robots/getting-started/introduction)Switch to Sitemap](https://nuxtseo.com/docs/sitemap/getting-started/introduction)Switch to Schema.org](https://nuxtseo.com/docs/schema-org/getting-started/introduction)Switch to Link Checker](https://nuxtseo.com/docs/link-checker/getting-started/introduction)Switch to SEO Utils](https://nuxtseo.com/docs/seo-utils/getting-started/introduction)Switch to Site Config](https://nuxtseo.com/docs/site-config/getting-started/introduction)Switch to Skew Protection](https://nuxtseo.com/docs/skew-protection/getting-started/introduction)Switch to AI Ready](https://nuxtseo.com/docs/ai-ready/getting-started/introduction)

**Core Concepts**

# **Build Cache**

For CI/CD environments, you can enable persistent build caching to skip regenerating images when the output would be identical between deployments.

## Setup

nuxt.config.ts

```ts
export default defineNuxtConfig({
  ogImage: {
    buildCache: true
  }
})
```

This stores rendered images in `**node_modules/.cache/nuxt-seo/og-image/**` during prerendering.

When using [**~~pnpm~~**](https://pnpm.io), this will be in the `**node_modules/.pnpm**` directory's cache structure. Consider using a [**~~custom cache directory~~**](#custom-cache-directory) for consistency.

## Invalidation

The cache automatically invalidates when:

- **Options change**: different title, description, or other props
- **Template changes**: the component file is modified
- **Module version changes**: you upgrade `**nuxt-og-image**`

**Automatic cleanup:** after each prerender, orphaned cache files (images no longer generated) are automatically cleaned up if they're older than 7 days. This prevents unbounded cache growth while preserving images that social platforms may still be referencing.

## CI Configuration

To persist the cache between CI runs, add the cache directory to your CI configuration:

```yaml
- name: Cache OG Images
  uses: actions/cache@v4
  with:
    path: node_modules/.cache/nuxt-seo
    key: og-images-${{ github.ref_name }}
```

## Custom Cache Directory

You can customize the cache location:

nuxt.config.ts

```ts
export default defineNuxtConfig({
  ogImage: {
    buildCache: {
      base: '.cache/og-image'
    }
  }
})
```

**Was this page helpful?**

### **Related **

[**Runtime Cache**](https://nuxtseo.com/docs/og-image/guides/runtime-cache)

[**Zero Runtime**](https://nuxtseo.com/docs/og-image/guides/zero-runtime)

[**Renderers**](https://nuxtseo.com/docs/og-image/renderers)

[**Security** Learn about the security defaults and how to further harden your OG image endpoint.](https://nuxtseo.com/docs/og-image/guides/security) [**Runtime Cache** How OG image caching works at runtime, including internal storage, CDN edge caching, and platform integration.](https://nuxtseo.com/docs/og-image/guides/runtime-cache)