惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
量子位
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
B
Blog
U
Unit 42
C
Check Point Blog
I
InfoQ
aimingoo的专栏
aimingoo的专栏
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
爱范儿
爱范儿

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
My API Responded in 4 ms, but Navigation Still Felt Slow
Awaliyatul Hikmah · 2026-06-20 · via DEV Community

I was debugging an internal project management application built with SvelteKit and a Rust API.

Locally, navigation felt almost instant.

On the VPS, opening the Tickets, Timeline, and OpenSpec docs pages felt noticeably slower. Clicking a ticket also took too long before the preview panel became useful.

My first assumption was infrastructure:

  • Maybe the VPS was underpowered.
  • Maybe PostgreSQL queries were slow.
  • Maybe the reverse proxy added latency.
  • Maybe SvelteKit SSR was taking too long.

The measurements pointed somewhere else.

The Baseline

I started with the feature list endpoint used by both Tickets and Timeline.

For a project with 52 tickets:

Metric Result
API response time ~4 ms
Response size 353,956 bytes
Number of tickets 52

The API was not slow.

But it was returning around 354 KB for a list of only 52 items.

The SvelteKit route payload showed the same pattern:

Route Data payload
Tickets 349,857 bytes
Timeline 354,731 bytes

This explained why local testing was misleading.

On localhost, transferring and parsing a few hundred kilobytes is easy to miss. Once the app runs behind a VPS, reverse proxy, TLS, and a real network connection, the payload becomes much more visible.

What Was Inside the Payload?

I broke down the feature response by field.

The descriptions alone accounted for:

296,177 bytes

That was more than 80% of the complete response.

The list endpoint was returning something similar to this for every ticket:

interface FeatureListItem {
  id: string;
  title: string;
  status: string;
  priority: string;
  storyPoints: number | null;
  dueDate: string | null;

  description: string | null;
  checkoutCommand: string | null;
  openSpecCommand: string | null;
}

The problem was not that these fields were useless.

They were useful on the ticket detail panel.

They were not useful when rendering the initial list.

Timeline was even more wasteful. It used ticket status, dates, dependencies, and assignees, but still downloaded every full Markdown description.

The Data Was Not a Toy List

This mattered because these pages were not rendering a simple table of titles.

In the production project I debugged, the Tickets data looked roughly like this:

Shape Count
Tickets 52
Completed tickets 52
Tickets with assignees 50
Tickets linked to OpenSpec docs 25
Scheduled tickets 41
Milestones 4
Dependency edges 28
Markdown description text ~299 KB
Largest single ticket description ~19 KB

So the ticket page was not only listing cards. It also had enough metadata to support filtering, preview panels, assignee display, milestones, dependencies, story points, and linked documentation.

The Timeline page reused the same ticket graph, but viewed it differently:

Shape Count
Scheduled items 41
Items with due dates 41
Items with start dates 35
Assignee lanes 6
Milestones 4
Dependency edges 28

Timeline needed dates, assignees, milestones, dependencies, and enough metadata for hover states and exports.

It did not need 299 KB of Markdown ticket descriptions.

OpenSpec docs had a different problem. The list endpoint was carrying document bodies and their task graph:

Shape Count / Size
Specs 26
Proposal content ~70 KB
Design content ~164 KB
Tasks markdown content ~97 KB
Spec files JSON ~158 KB
Linked task rows 576
Largest spec content bundle ~36 KB

That data is legitimate on a detail screen.

It is too much for opening the OpenSpec docs menu.

The issue was not that the application had complex data. The issue was that the first navigation step paid the cost of data that belonged to later interactions.

Why SvelteKit Made It Visible

The page loader was straightforward:

const features = await api.getFeatures(projectId);

return {
  features
};

Because features contained the full ticket objects, SvelteKit serialized the complete array into its route data response.

It did not matter that Timeline never rendered description.

The loader returned it, so it crossed the network.

This was the important distinction:

UI usage does not determine the payload. The loader return shape does.

The database query could finish in a few milliseconds while the browser still had to download, parse, deserialize, and hydrate hundreds of kilobytes.

The Root Cause

The feature list endpoint had slowly become a detail endpoint.

It started as a convenient shared API. Over time, more fields were added because different pages needed them.

Eventually, every list consumer received the union of all possible requirements.

That made the endpoint easy to reuse, but expensive to consume.

The same pattern also existed in the OpenSpec docs page. Its list request was carrying full document content even though the initial screen only needed document metadata.

The Fix

I separated summary data from detail data.

The list contract became:

interface FeatureListItem {
  id: string;
  title: string;
  status: string;
  priority: string;
  featureType: string;
  milestone: string | null;
  startDate: string | null;
  dueDate: string | null;
  storyPoints: number | null;
  dependencies: string[];
  labels: string[];
  assignee: CompactUser | null;
}

The detail contract extended it:

interface FeatureDetailItem extends FeatureListItem {
  description: string | null;
  checkoutCommand: string | null;
  openSpecCommand: string | null;
}

The API was split into two responsibilities:

GET /projects/:projectId/features
GET /projects/:projectId/features/:featureId

The first endpoint returns summaries.

The second returns one complete ticket.

The database query for the list endpoint also stopped selecting the description and stopped joining data needed only to generate implementation commands.

Loading the Preview Without Blocking the List

The Tickets page still needed to open a preview panel when a card was selected.

Instead of delaying the entire page, the interaction became:

  1. Render the ticket list from summary data.
  2. Open the preview shell immediately using the selected summary.
  3. Fetch the complete ticket in the background.
  4. Cache the detail response by ticket ID.
  5. Render the Markdown description when it arrives.

In simplified form:

const featureDetails: Record<string, FeatureDetailItem> = {};

async function loadFeatureDetail(featureId: string) {
  if (featureDetails[featureId]) {
    return featureDetails[featureId];
  }

  const response = await fetch(
    `/projects/${projectId}/features/${featureId}/detail`
  );

  const feature = await response.json();
  featureDetails[featureId] = feature;

  return feature;
}

Direct navigation to a selected ticket still loads the summary list and the selected detail concurrently on the server.

So the optimization did not remove functionality. It changed when the expensive data was requested.

The Result

After separating list and detail payloads:

Response Before After Reduction
Feature list API 353,956 B 36,911 B 89.6%
Tickets route data 349,857 B 30,192 B 91.4%
Timeline route data 354,731 B 34,967 B 90.1%

A selected ticket detail was around:

20,658 bytes

But that payload is now requested only when the user selects the ticket.

The OpenSpec docs page had the same optimization applied:

Response Before After Reduction
OpenSpec docs API 681,558 B 7,257 B 98.9%
OpenSpec docs page data 704,385 B 39,516 B 94.4%

The database was fast before and remained fast afterward.

The meaningful improvement came from sending less data through the complete request path.

What Would Not Have Fixed It

A loading indicator could make the delay less confusing, but it would not remove the delay.

Optimizing the PostgreSQL query would also have targeted the wrong layer. The API already responded in a few milliseconds.

Code splitting the frontend bundle would not remove data returned by +page.server.ts.

The bottleneck was the contract between the list page and the API.

Takeaways

The main lesson was simple:

A fast query does not automatically produce a fast page.

For list-heavy applications:

  1. Measure response size, not only response time.
  2. Treat list and detail payloads as different contracts.
  3. Do not return large text fields unless the current view needs them.
  4. Check what the SSR loader serializes into route data.
  5. Measure shared endpoints from every consumer's perspective.
  6. Lazy-load detail data, but render the interaction shell immediately.
  7. Cache detail responses when users may reopen the same item.
  8. Do not use a spinner as a substitute for removing unnecessary work.

In this case, the VPS was not the real problem.

It only exposed a payload problem that localhost had been hiding.