1
0 Comments

Obsidian Blog Tool:Week 3 - Wrestling with Vercel Caches

Hi there! I'm James and I've started building a product (name TBD) that lets you easily publish blogpost from Obsidian, a markdown based note-taking tool, similar to Notion. Last week, I've built a basic dashboard and added some integration tests . I meant to work on getting my Obsidian plugin to a publishable state, but unfortunately, I was stuck on figuring out how the Vercel cache revalidation works for wildcard domains.

Vercel cache revalidation

Vercel is a hosting platform who made NextJS. Since NextJS 12.2, they've offered revalidate API, which would trigger a rebuild of a statically generated page. This functionality is important for my product, as I'd need to trigger a rebuild every time someone updates a post. Otherwise, users will keep seeing the old version of the post!

Problem with Vercel cache revalidation

I've used this API before, and have tested it out in my POC before starting working on this project. However, I've recently realised it stopped working 😱. When I started debugging, I found out that this problem was limited to for my wildcard subdomains.

To make a long story short, the problem was that Vercel will only clear the cache for a path for a particular domain.  i.e.
Given that you want to revalidate a.test.com

  • calling a.test.com/api/revalidate 🟢
  • calling test.com/api/revalidate ❌
  • calling b.test.com/api/revalidate ❌

For more details, you can read the issue I've raised on the NextJS repo:
res.revalidate does not clear Vercel cache under certain condition when using wildcard subdomains · Issue #45269 · vercel/next.js · GitHub

Debugging this issue took me the whole week as I can only work on this project 1~2 hours per day. Which means none of my goals from last week was completed. But on the bright side, I now have an automated integration test that tests the Vercel cache changes.

What's next

I'm feeling a little bit drained after all the debugging. My aim for this week is to:

  1. Make publishing logic more fault-tolerant (last week's goal)
  2. Plan out/ write out what to put on a landing page.

Thank you for reading so far and I'll see you next week!

on January 30, 2023