DEV Community

tumao
tumao

Posted on • Updated on

Next app

So, I decided that my front-end would be in Next.js.

The norm for Next.js is Vercel, but since this is DO hackaton, I decided that trying alternative is the way to go.

But there came a problem.

Image loading is waaay too slow. I am aware that next does image optimization on-the-fly.
So I decided to upgrade to the $10 plan, to see if that is acceptable. Not better at all.

Vercel uses CDN for caching the images. So I decided to use Cloudflare to eliminate this issue.

And I found this quote in the docs "App Platform apps cannot be routed through your own Cloudflare account and must instead use App Platform's built-in CDN functionality."

The built-in CDN does not seem to be helping AT ALL.

Anyone got a solution?

Update

The solution was to change the Cache headers on the images hosted on S3. Next.js app would then use the cache settings from the header.

So what was happening?
Next.js app was caching the generated images for only 60 seconds, which ment that almost every visitor would be waiting.

After this, the development was super easy. Everything worked as expected.

Top comments (0)