0

I'm building a blog site using next.js with Notion as my CMS.

I use the official Notion API (by way of the JS client) to fetch page content which I then transform into HTML and render.

I want to eventually leverage next.js to cache as much as possible for as long as possible and only invalidate the cache on edits. But the problem then is that embedded media links returned from Notion are expiring, and so can't be plainly cached as-is.


In mulling over the situation I've considered the following options:

  1. Serve the expiring links as-is and have next.js invalidate the cache before the expiration hits. Seems a bit overkill as it triggers regeneration/re-fetching of the entire page content just to refresh links.
  2. Convert images to base64 and embed them in the text. This is really slow, and doesn't work for videos (or effortlessly for images either).
  3. Use external links only and manually upload media elsewhere. Seems a little fragile, and tedious to manage (keeping sources in sync etc.)
  4. Set up an automation pipe somewhere that caches media and creates non-expiring links (fetch, upload, new link etc.). Makes me wonder why I'd use next.js at all if I had something like this set up.

Is there a particular approach I might do well to consider here?

Smidgens
  • 1
  • 1

0 Answers0