The @vercel/og
package is used to generate open graph images dynamically. In order to cache the images, you can use a CDN like Vercel Edge Network.
Here's an example of how to cache using Vercel Edge Network:
index.tsx419 chars14 lines
By adding the Cache-Control
header with a s-maxage
of 86400 seconds (24 hours), you are instructing the CDN to cache the response for up to 24 hours. The stale-while-revalidate
parameter allows the CDN to serve cached content while refreshing the cache in the background.
Note: The specific caching headers and values can be adjusted according to your needs.
gistlibby LogSnag