letto
February 17, 2024, 11:07pm
1
I noticed Koyeb actually uses Vercel to host it’s landing page, not itself, why?
How do I set cache headers for the Next.js html pages and static files? Html is never cached.
Why do the Koyeb cache headers say this (nextjs css file) has a long cache time but it expires after 30 seconds?
Some pictures of Koyeb response, Koyeb waterfall, and Vercel waterfall last, same app.
letto
February 18, 2024, 1:38am
2
There are 3 things to cache here, Vercel caches all these permanently and clears the cache on a new deploy.
The HTML pages.
Generated static assets like CSS and JS.
Files in the /public folder like images or JS.
Edit:
Found how to cache the public folder when hosting outside of Vercel:
const nextConfig = {
headers() {
if (process.env.NODE_ENV !== 'production') return []
return [
{
source: '/:all*(css|js|gif|svg|jpg|jpeg|png|woff|woff2)',
locale: false,
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000',
},
],
},
]
},
}
1 Like
letto
February 18, 2024, 9:26pm
3
Exploring further here, one reason reason app.koyeb.com may feel slow is due to static assets not being cached. The html TTFB is also a bit slow.
The css file and fonts are blocking rendering, but take 150-700 ms instead of 50-100 ms if they were cached.
letto
February 18, 2024, 9:53pm
4
Otherwise I like the platform, builds well and nice metrics.
letto
February 19, 2024, 12:34am
5
I can’t edit or delete the original post anymore… just ignore question 2 as it’s more a next.js question.
Question 3 still stands and essentially asks why the cache header is ignored.
Does Koyeb recommend using Cloudflare for your website with custom rules and such? How does that work if Koyeb already uses Cloudflare? Can’t find info in the docs about this.
This may already be possible, I haven’t tried to cdn cache next.js like this before.
Caching is an effective technique for improving performance and reducing latency speeds for the requests of your web services and apps. CDNs bring your content even closer to end-users. Learn about cache control: what it is, how to configure it, and...