Applying Dynamically Generated Open Graph (OG) Images to Inflearn Content
Key point
Inflearn built a system that dynamically generates and caches content-specific OG images using @vercel/og and a CDN.
Details
Inflearn introduced dynamic OG (Open Graph) images on its course review and Q&A pages so that content can be understood at a glance when shared on SNS. Previously, only the Inflearn slogan was displayed, making it hard to know the specific content of what was shared, so this was improved to increase click-through rates.
For image generation, the @vercel/og library, which converts HTML/CSS into SVG, was used. This library runs on the Edge runtime, and quickly generates images containing the content's title and body through the API router of the Next.js project.
To reduce the cost of regenerating images every time, AWS CloudFront (CDN) was introduced to apply caching. In particular, by including the DB's updatedAt value in the URL, an efficient cache invalidation strategy was implemented so that new images are only generated when content is modified.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.