Skip to content

Conversation

@harlan-zw
Copy link
Collaborator

Summary

  • Adds buildCache config option for persistent caching of rendered OG images between CI runs
  • Cache key includes options hash, component template hash, and module version for automatic invalidation
  • Stores cache in node_modules/.cache/nuxt/og-image/ by default

Usage

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

Cache 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

CI Configuration

- uses: actions/cache@v4
  with:
    path: node_modules/.cache/nuxt/og-image
    key: og-images-${{ hashFiles('**/package-lock.json') }}

Test plan

  • Unit tests for hashOgImageOptions() with componentHash/version params
  • E2E test verifying cache directory creation and file storage
  • Manual testing in playground

🤖 Generated with Claude Code

harlan-zw and others added 2 commits January 10, 2026 12:35
Adds a new `buildCache` option that enables persistent caching of rendered
OG images between CI runs. The cache key includes:
- Options hash
- Component template hash (busts cache when template changes)
- Module version (busts cache when og-image version changes)

Cache is stored in `node_modules/.cache/nuxt/og-image/` by default and
respects the existing `cacheMaxAgeSeconds` TTL.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Build Cache (CI Persistence) section to cache guide
- Add buildCache option to config API docs
- Add e2e test to verify cache directory creation and file storage
- Fix buildCacheDir to use absolute path from nuxt.options.rootDir
- Add playground config comment for buildCache option

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@harlan-zw
Copy link
Collaborator Author

Code Review Summary

Reviewed PR #413 for potential bugs and code quality issues.

Result: No high-confidence issues found

All issues identified scored below the 80% confidence threshold for automated reporting. The implementation follows the existing codebase patterns appropriately.

Lower-confidence observations (not actionable)
Issue Score Note
JSON.parse without try-catch 72% Cache written by same module, low corruption risk
Expiry from build time 72% Reasonable for CI caching with 72hr default
Missing null check on cached.data 42% Type-safe write path prevents normal occurrence
mkdirSync error handling 28% Standard CI paths are writable
Test comment/variable name mismatch 25% Code quality, not functional bug
Pre-existing TODO incomplete 25% Out of scope for this PR
Hash function inconsistency 15% simpleHash serves different purpose (URL-safe)

Automated review by Claude Code

@harlan-zw harlan-zw changed the title feat: add CI-persistent build cache for OG images feat: CI build cache Jan 11, 2026
@harlan-zw harlan-zw merged commit 51f23ff into main Jan 11, 2026
4 checks passed
@harlan-zw harlan-zw deleted the feat/ci-persistent-cache branch January 11, 2026 04:04
@harlan-zw harlan-zw mentioned this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants