YoonCarrot Home
Series3D Library

YoonCarrot© 2026 Yoon Carrot. All rights reserved.
All postsGitHubEmailTerms of ServicePrivacy PolicyRSS
Read in other languages:한국어日本語简体中文
Introduction/Blog

[Blog Intro] Global Blog Performance Optimization

Carrot YoonCarrot Yoon·2026-11-24·16 min·5

#CDN#Lighthouse#Cloudflare
Contents (18)
  1. [Blog Intro] Global Blog Performance Optimization — Network & App Layer
  2. What Makes Global Performance Optimization Different?
  3. Problem Definition & Solutions
  4. Diagnosing & Fixing the Network Layer
  5. Issue 1. Overseas DNS Lookups
  6. Issue 2. Short Cache Expiration Time
  7. Issue 3. Next.js Proxy Matcher & Dynamic Handling of Static Files
  8. Issue 4. Separating the Image CDN & Migrating GCS -> Cloudflare R2
  9. Diagnosing & Fixing the Application Layer
  10. Issue 1. Client-Side Mermaid Rendering in Posts
  11. Issue 2. Responsive Images Inside Posts
  12. Issue 3. Duplicate Inline CSS in HTML & RSC
  13. Issue 4. Heavy Initial JS Dependencies (Radix, Recharts, Sentry, GA)
  14. Issue 5. Prefetch Flood Matching Every Link on the Page
  15. Final Before & After Comparison
  16. Real-World Limitations Encountered
  17. Final Network & Caching Architecture (Before / After)
  18. Closing Thoughts

[Blog Intro] Global Blog Performance Optimization — Network & App Layer

This post was written 30% by AI and 70% by a human.

In my previous post, I added multi-language support for Korean, English (en), Japanese (ja), and Simplified Chinese (zh-CN). This time, I want to share how I optimized web performance for a truly global audience.

My first performance optimization attempt (over a year ago)

After this global performance optimization

image.webp

image.webp

It has been over a year since I first wrote about performance optimization. Back then, the blog was Korean-only, yet I insisted on benchmarking it on overseas low-end mobile environments to see how much it improved (left image).
Honestly, for a Korea-only site, measuring overseas performance without a real reason was pretty silly—I was basically shadowboxing a problem that didn't exist.

And if you asked whether I actually did overseas optimization well back then, the answer is no—I was tunnel-visioned on FCP and LCP and missed the bigger picture. Now that the blog is genuinely open to global readers, I had clear goals and concrete bottlenecks to solve (right image). If you have ever benchmarked overseas mobile performance on debugbear.com, you know how hard it is to get numbers like that! Nice!

What Makes Global Performance Optimization Different?

When you only serve users in Korea, performance metrics usually look great out of the box. Most infrastructure lives in Korean regions, so network latency is tiny and everything else looks good by extension.

Global services are a completely different story. You need to understand the entire path that static assets and server responses travel to reach users around the world before you can optimize effectively.

So I split this optimization clearly into two layers:

  1. Network layer: Redesign the routing path so responses are served as close to the user as possible from anywhere in the world.

  2. App layer: Accept that overseas users often have slower networks (3G) and lower-end devices than Korea, and make the app send less and execute less even under heavy CPU throttling.

In this post, I document how I cross-measured desktop, mobile, and global performance using Globalping (US, Germany, Japan, South Korea), PageSpeed Insights, and DebugBear (7 global regions, mobile & desktop) to push performance up across the board.

Problem Definition & Solutions

First, here is a summary of what the problems were, how I solved them, and what impact they had.

Previous Problems (Why)

Built around domestic servers, causing both network latency and browser main-thread overhead on lower-end devices.

  • Network / Infrastructure

    • Slow overseas DNS queries (over 1s)

    • High TTFB (2–6s+)

    • Overseas users hitting a Seoul Nginx CDN

  • Application Code

    • Duplicate inlineCss payload delivery

    • Shipping a heavy client-side Mermaid renderer

    • Shipping framer-motion

    • Large initial JS bundle

    • Excessive Next.js link prefetches

Solution Architecture (How)

Stop making data travel around the globe.
Move work to static/SSR rendering wherever possible.
Keep the browser's main thread light.
Shrink every resource as much as possible.

  • Network / Infrastructure

    • Migrated Gabia DNS => Cloudflare DNS

    • Migrated GCS => Cloudflare R2

    • Separated static asset domain from backend
      api.yooncarrot.com/static =>
      cdn.yooncarrot.com/

  • Application Code

    • Moved Mermaid rendering to SSR

    • Removed framer-motion

    • Replaced Radix on home with lightweight components

    • Deferred loading of Sentry, GA, etc.

    • Disabled unnecessary prefetches

Impact (Benefit)

Reduced global network latency, browser main-thread load, and infrastructure costs.

  • Network / Infrastructure

    • Global edge-cached images via R2

  • Code Optimization

    • Home HTML 66KB → 26~28KB (-58%)

    • Initial JS 890KB → 264KB (-70%)

    • Initial _rsc prefetches 0

Let's walk through each of these improvements one by one.

Diagnosing & Fixing the Network Layer

First, I measured how fast—or slow—the blog actually felt from overseas regions.

Metric

Before Optimization

Bottleneck Layer

Overseas DNS lookup (US/DE/JP/KR)

77~1,072ms

Network (domestic-only DNS)

Home HTML TTFB (REVALIDATED)

US 4.1s · DE 6.1s · JP 3.5s · KR 2.2s

Network (short ISR expiration)

Image Cold MISS (Caddy → GCS)

DE 1,515ms · US 667ms · JP 288ms

Network (single Seoul VM hop)

Issue 1. Overseas DNS Lookups

Because I was still using my Korean domain registrar's (Gabia) nameservers, just resolving the domain from overseas took 200~480ms (and occasionally up to 1,072ms). Simply moving nameservers to Cloudflare Free DNS stabilized DNS lookups across all four countries to 9~115ms. I honestly never imagined DNS alone could slow things down that much.

Issue 2. Short Cache Expiration Time

Region (Vercel Edge)

Accept-Language

Response / Target

Cold TTFB (Before)

Cold TTFB (After)

US (sfo1 · cle1)

en-US

307 → /en

5.07 ~ 5.14s

0.48 ~ 0.50s

Germany (fra1)

de-DE

307 → /en

5.11 ~ 7.06s

0.42 ~ 0.86s

Japan (hnd1)

ja-JP

307 → /ja

2.70 ~ 3.50s

0.20 ~ 0.23s

South Korea (icn1)

ko-KR

200 (stays /)

3.59 ~ 4.07s

0.22 ~ 0.35s

The cache expire time was set to 3,600 seconds—the same as revalidate. If nobody visited for an hour, the cache expired completely, forcing the next overseas visitor to stare at a blank screen until the Vercel → Seoul Spring API round trip finished. Extending expire to 7 days fixed this dramatically.

Issue 3. Next.js Proxy Matcher & Dynamic Handling of Static Files

In Tokyo (hnd1), static JS under /_next/static took only 15~19ms, yet /favicon.ico took 607ms (and 1,015ms in Singapore). The reason was that proxy.ts's matcher intercepted root static files too and only passed them through inside the function.

By excluding [^/]+\.[^/]+$ and \.well-known directly in the matcher regex, files like /favicon.ico, /sw.js, /robots.txt, and /sitemap.xml completely bypass the middleware. Tokyo's /favicon.ico HIT latency dropped from 607ms → 32ms (19x faster).

Without middleware, the request only travels [User -> Vercel CDN Edge]. With middleware, it goes through [User -> Vercel Edge -> Proxy Middleware -> Static File Resolution], adding massive overhead.

Issue 4. Separating the Image CDN & Migrating GCS -> Cloudflare R2

  1. Domain separation (cdn.yooncarrot.com)

    • I separated the file server domain from api.yooncarrot.com/static to cdn.yooncarrot.com so static assets hit Cloudflare CDN directly without routing through the Seoul backend server.

  2. Migrating GCS → Cloudflare R2 (yooncarrot-storage)

    • I copied existing GCS objects into R2 using Cloudflare Super Slurper and connected cdn.yooncarrot.com directly as an R2 Custom Domain, unlocking Cloudflare's global CDN edge.

Country

Pre-R2 Cold MISS TTFB
(Seoul Caddy→GCS, Before)

Post-R2 MISS TTFB
(Total, After)

Cold MISS Improvement

Post-R2 Edge HIT TTFB (Total)

Germany (DE)

1,515ms (Total 1,563ms)

346ms (Total 407ms)

-77.2% (4.4x faster)

34ms (Total 61ms)

US (US)

667ms (LA actual 200 MISS, Total 917ms)

246ms (LA 199ms / Total 241ms)

-63.1% (LA -70.2%)

68ms (Total 146ms)

Japan (JP)

288ms (Total 319ms)

88ms (7.4KB logo 56ms)

-69.4%

17ms (Total 37ms)

South Korea (KR)

61ms (Total 117ms)

115ms (Total 150.5ms)

+54ms (first request only)

14ms (Total 73.5ms)

Diagnosing & Fixing the Application Layer

No matter how much you trim network latency, the site still feels sluggish if HTML is bloated or the browser's main thread is tied up running JS and forced reflows. In the app layer, I focused on moving server-capable work to the server and stripping out duplication, waste, forced reflows, and unnecessary client dependencies.

Metric

Before Optimization

Bottleneck Layer

Home HTML / Initial JS transfer

HTML 66KB (uncompressed 551KB) · JS 890KB

App (inlineCss duplication · bloated bundle)

Post runtime / Image waste

Forced Reflow 90.2ms · Image waste 628 KiB

App (framer-motion · mermaid · unresized original images)

Issue 1. Client-Side Mermaid Rendering in Posts

Previously, the user's browser converted Mermaid code into diagrams on the client. That caused layout reflows, hurt CLS, and forced the browser to download a hefty client-side Mermaid bundle.

So I moved Mermaid rendering to SSR using the beautiful-mermaid library so diagrams are pre-rendered and cached on the server. Users no longer need to render Mermaid in the browser, and eliminating the DOM mutation eliminated the reflow too.

Issue 2. Responsive Images Inside Posts

Blog posts contain user-uploaded images rather than static images hardcoded in VS Code, so I hadn't originally thought to make them responsive (even though the home page already used responsive images). That dragged down Lighthouse performance scores.

Then I realized I could inject srcset (640/828/1080/1200) and sizes onto every <img> tag during SSR so Next.js serves properly sized images. After applying this, image transfer size dropped from 618 KiB → 13 KiB (-98%).

Issue 3. Duplicate Inline CSS in HTML & RSC

Earlier, I had turned on experimental.inlineCss: true thinking it would reduce CSS requests.

When I inspected the deployed HTML, however, over 175KB of global CSS was being embedded twice—once inside <style> and again inside Next.js's RSC stream (__next_f). Worse, because it was inlined into HTML, browsers couldn't cache it and re-downloaded it on every page visit.

Switching to inlineCss: false restored external CSS caching, and excluding unused component paths in globals.css trimmed 31.7KB of CSS itself.

As a result, home HTML shrank by more than half: 66KB → 26~28KB (-58%, -64% uncompressed).

Issue 4. Heavy Initial JS Dependencies (Radix, Recharts, Sentry, GA)

Even though the home page is basically a simple post list, it was shipping 890KB of initial JS. Inspecting the production chunks showed that the bottom-of-page statistics chart (Recharts), theme modal, and Sentry/GA were all loading upfront—and even the Avatar menu was pulling in @radix-ui/react-dropdown-menu, adding 39KB compressed on its own.

So I deferred everything not immediately needed: Recharts loads via IntersectionObserver when scrolled into view, the theme modal loads on click, and Sentry and GA/GTM wait until the first user interaction.

The home page now ships 0 Radix chunks, and initial JS dropped from 890KB → 263.8KB (-70%).

Issue 5. Prefetch Flood Matching Every Link on the Page

Next.js's <Link> defaults to prefetching any linked route that enters the viewport. Simply landing on the home page or an article triggered 5 _rsc requests on home and over 30 on article pages for links the user hadn't even hovered.

Adding prefetch={false} to header, list, category, footer, and tag links brought initial _rsc prefetches down to 0 everywhere.

Some might ask, "Why give up one of Next.js's perks? At least prefetch on hover!"—and that is certainly a fair follow-up option.

Payload Metric

Before

Final (Stage 10)

Change

Home HTML size (transferred / uncompressed)

66KB / 551KB

26.3~27.8KB / 201KB

-58% / -64%

Home initial JS / Total transfer (desktop)

890KB / 1,072~1,243 KiB

263.8KB / 376~377KB

-70% / -65%

Initial _rsc prefetches / Home Radix chunks

5 on home · 30+ on post / 3 Radix chunks

0 / 0

Completely eliminated

Article page (/article/79) total transfer

1,178KB

498~530KB

-55~58%

Final Before & After Comparison

Here are the results across all 4 Lighthouse categories (Performance, Accessibility, Best Practices, SEO), measured over 2 pages (home, post) × 2 locales (ko, en) × 2 devices (mobile, desktop) × 3 runs each.

Target Page [Device]

Before

After
(P / A / BP / SEO)

FCP / LCP (median)

TBT / CLS

Total / JS

ko-home [desktop]

85 (TBT 310ms)

96 / 100 / 100 / 100

299ms / 299ms

19ms / 0

377KB / 263.8KB

ko-home [mobile]

79 (CLS 0.226)

100 / 100 / 100 / 100

961ms / 961ms

27ms / 0

405KB / 263.8KB

en-home [desktop]

79 (TBT 470ms)

99 / 100 / 100 / 100

286ms / 286ms

24ms / 0

376KB / 263.8KB

en-home [mobile]

68 (LCP 3.9s · CLS 0.226)

100 / 100 / 100 / 100

959ms / 959ms

34ms / 0

406KB / 263.8KB

ko-post [desktop]

78 (TBT 460ms)

99 / 100 / 100 / 100

350ms / 359ms

28ms / 0.0032

521KB / 307.2KB

ko-post [mobile]

67 (TBT 810ms · CLS 0.226)

99 / 100 / 100 / 100

1,051ms / 1,052ms

24ms / 0.0041

530KB / 307.2KB

en-post [desktop]

73 (TBT 690ms)

100 / 100 / 100 / 100

298ms / 298ms

12ms / 0.0032

525KB / 307.1KB

en-post [mobile]

67 (TBT 820ms · CLS 0.226)

100 / 100 / 100 / 100

1,051ms / 1,051ms

16ms / 0.0030

498KB / 307.1KB

And below is a summary of the debugbear.com global results shown at the top.

Test Region

Mobile (P / A / BP / SEO)

Desktop (P / A / BP / SEO)

Germany

95 / 100 / 100 / 100

98 / 96 / 100 / 100

Japan

94 / 100 / 100 / 100

99 / 96 / 100 / 100

South Africa

94 / 100 / 100 / 100

94 / 96 / 100 / 100

South Korea

93 / 100 / 100 / 100

98 / 96 / 100 / 100

Brazil

90 / 100 / 100 / 100

97 / 96 / 100 / 100

Taiwan

86 / 100 / 100 / 100

98 / 96 / 100 / 100

US East

76 / 100 / 100 / 100

96 / 96 / 100 / 100

Overall Average (14 runs)

Perf 93 · A11y 98 · BP 100 · SEO 100

All regions BP 100 · SEO 100

Real-World Limitations Encountered

First-Hit R2 MISS in Korea & Free-Tier Edge Routing

Previously, both the GCP VM and GCS lived in the Seoul region, so Korean visitors actually had a slightly snappier first-hit experience.

With Cloudflare R2, APAC storage typically sits near Tokyo or Singapore, and under heavy traffic on the free plan requests can even route via Tokyo or LA edges—meaning Korea can occasionally be slower (taking a detour around the globe instead of right next door!).

React/Next.js Baseline Cost on Ultra-Low-End Mobile

Google PSI Mobile hit 100, and DebugBear scored 90+ across Germany (95), Japan (94), South Africa (94), South Korea (93), and Brazil (90).

However, on DebugBear US-East Mobile—which has the harshest CPU throttling—even maximum optimization topped out at 76. Pushing ultra-low-end mobile devices any further likely isn't feasible without dropping React/Next.js altogether.

inlineCss: false First-Visit 1 RTT & RUM Verification

Setting inlineCss: false shrank all HTML by 58% and enabled 0ms cached CSS on repeat visits, at the cost of 1 extra RTT for the external stylesheet on a cold first visit.

Also, synthetic scores (PSI and DebugBear) are simulations and can differ from what real overseas visitors experience.

That's why collecting Real User Monitoring (RUM) data via GA4 Web Vitals and Vercel Speed Insights is crucial to spot real bottlenecks.

Final Network & Caching Architecture (Before / After)

77-1072ms yooncarrot.com REVALIDATED 2.2-6.1s api.yooncarrot.com/static (DE MISS 1.5s) 66KB HTML + 890KB JS Global User (US / DE / JP) Gabia DNS Vercel Edge (ISR 1h / inlineCss) Seoul GCP VM (Spring + Caddy) GCS Seoul Heavy JS (mermaid + framer + Radix)
flowchart LR
  User["Global User (US / DE / JP)"] -->|"77-1072ms"| DNS["Gabia DNS"]
  DNS -->|"yooncarrot.com"| Vercel["Vercel Edge (ISR 1h / inlineCss)"]
  Vercel -->|"REVALIDATED 2.2-6.1s"| Origin["Seoul GCP VM (Spring + Caddy)"]
  DNS -->|"api.yooncarrot.com/static (DE MISS 1.5s)"| Origin
  Origin --> GCS[("GCS Seoul")]
  Vercel -->|"66KB HTML + 890KB JS"| ClientJS["Heavy JS (mermaid + framer + Radix)"]

Network and app rendering bottlenecks before optimization

9-115ms yooncarrot.com 28KB HTML + SSR + srcset cdn.yooncarrot.com (HIT 37-146ms) Cold MISS (DE 346ms / US 246ms) Global User (US / DE / JP) Cloudflare DNS Vercel Edge (ISR 1h/7d / Static Bypass) Slim JS (264KB / Zero Radix / Reflow0ms) Cloudflare Edge (31d Cache) Cloudflare R2
flowchart LR
  User["Global User (US / DE / JP)"] -->|"9-115ms"| DNS["Cloudflare DNS"]
  DNS -->|"yooncarrot.com"| Vercel["Vercel Edge (ISR 1h/7d / Static Bypass)"]
  Vercel -->|"28KB HTML + SSR + srcset"| ClientJS["Slim JS (264KB / Zero Radix / Reflow<br/>0ms)"]
  DNS -->|"cdn.yooncarrot.com (HIT 37-146ms)"| CF["Cloudflare Edge (31d Cache)"]
  CF -->|"Cold MISS (DE 346ms / US 246ms)"| R2[("Cloudflare R2")]

Global edge, direct R2 delivery, and slimmed app architecture after optimization

Closing Thoughts

This was actually my first time doing full-scale performance optimization for a global environment. I learned that delivering a great web experience requires understanding everything end-to-end, from frontend code to networking.

I also realized how important it is to be clear about why you are optimizing. Chasing high scores for their own sake isn't the point—you optimize because there is a real need (which I think is an essential mindset for any developer, not just for performance work).

In short, meaningful performance improvement requires optimizing both layers together:

  1. Network / infrastructure layer: keep user requests from traveling halfway around the planet, and

  2. App layer: properly optimize APIs and client resources.

Of course, digging deeper on the frontend brings even more topics like parallel processing, avoiding main-thread blocking, and optimizing React's lifecycle.

Today I focused on the changes that mattered most for a global audience. Even with AI helping, writing this post took ages because there was so much to trim down. 🥲

Wishing everyone the best in this great era of AI!

Contents

  1. [Blog Intro] Global Blog Performance Optimization — Network & App Layer
  2. What Makes Global Performance Optimization Different?
  3. Problem Definition & Solutions
  4. Diagnosing & Fixing the Network Layer
  5. Issue 1. Overseas DNS Lookups
  6. Issue 2. Short Cache Expiration Time
  7. Issue 3. Next.js Proxy Matcher & Dynamic Handling of Static Files
  8. Issue 4. Separating the Image CDN & Migrating GCS -> Cloudflare R2
  9. Diagnosing & Fixing the Application Layer
  10. Issue 1. Client-Side Mermaid Rendering in Posts
  11. Issue 2. Responsive Images Inside Posts
  12. Issue 3. Duplicate Inline CSS in HTML & RSC
  13. Issue 4. Heavy Initial JS Dependencies (Radix, Recharts, Sentry, GA)
  14. Issue 5. Prefetch Flood Matching Every Link on the Page
  15. Final Before & After Comparison
  16. Real-World Limitations Encountered
  17. Final Network & Caching Architecture (Before / After)
  18. Closing Thoughts