跪拜 Guibai
← All articles
Frontend

Don't Ship 25,000 Quiz Answers at Once: Split, Cache, and Prefetch

By SGAMERrain ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A quiz that ships its entire 25,000-answer bank before the first question wastes bandwidth and slows first render; splitting and prefetching keep a timed answer game responsive without forcing validation server-side.

Summary

An online quiz with 300+ questions and 25,000+ compiled answers cannot reasonably push the whole answer bank to the browser before the first question. One JSON file with everything is the simplest option: no extra requests after download, but first-screen download, JSON parsing, and memory use all grow with the data. The metric that matters is compressed transfer size, parse time, and runtime memory, not raw answer count.

Two split strategies reduce the initial payload. Category-based files, such as animals.json and geography.json, load only what a player enters and cache it for reuse, at the cost of cache memory and the need for limits, version updates, and retry handling. A separate question index plus per-question answer files decouples "what question comes next" from "which answers are valid", but creates more requests when switching questions.

A 25-second-per-question format makes network latency part of gameplay, so prefetching the next question's answer data matters. When the compressed bank is only tens of KB, bundling is good enough; multi-MB banks justify splitting or server-side validation. The order of work is measure first, then split, cache, prepare current question data before the timer starts, and prefetch.

Takeaways
— Answer count alone does not determine payload size; compressed transfer size, parsing time, and runtime memory are the real metrics.
— Bundling all questions and answers into one JSON file is simplest and can be good enough when the compressed file is only tens of KB.
— Category-split JSON files load only the category a player enters and cache it for reuse, but the cache needs size limits, version updates, and retry logic.
— Separating the question index from per-question answer files keeps "next question" data independent of "valid answers", at the cost of more network requests on question switches.
— With a 25-second timer, prefetching the next question's answer data prevents network latency from eating into the countdown.
— Krillion Infinite is a free, unofficial browser quiz practice game with 300+ questions, 25,000+ compiled answers, six rarity tiers, and Classic and Endless modes.
— Measure full bank size and parse cost first, then split by usage, cache loaded data, ensure current validation data is ready before the timer, and prefetch later questions.
Conclusions

Category splitting only helps when a player actually stays inside one category; a quiz that draws from all categories across questions still ends up fetching many files.

The 25-second timer turns answer loading into a latency problem, so prefetching can matter more than shaving payload size.

Keeping the full answer bank off the client ultimately pushes validation to the server, which hides the data but puts network round-trips inside the answer-check path.

Static file organization can solve most of this problem; state management and databases are not needed just because the dataset is large.

Concepts & terms
On-demand loading
Fetching data only when a user needs it, rather than bundling the whole dataset in the initial page load.
Answer index
A lightweight per-question structure that maps question IDs to separate answer files, letting the client know what question is next without loading every valid answer.
Prefetching
Loading the next question's answer data before the player reaches it, so the network request happens during the current question instead of during the countdown.
From the discussion
Featured comments
组合搭配函数

Splitting by question is exactly the right approach — stuffing 25,000+ answers into the initial load is just making trouble for yourself. Putting answer validation on the server also gets to the root of it; the frontend only needs to handle display.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗