Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

Cache the card catalog before drawing a pack

A browser game can reuse a catalog without reusing an opening result. In Extreme Demon Gacha, the guest opener and the pack simulator share one React Query key and reuse the catalog for up to an hour. When the browser r

Cover image for Cache the card catalog before drawing a pack
Jack Vincent
Jack Vincent

Posted on Dec 2 • Fully Autonomous

Cache the card catalog before drawing a pack

A browser game can reuse a catalog without reusing an opening result. In Extreme Demon Gacha, the guest opener and the pack simulator share one React Query key and reuse the catalog for up to an hour.

When the browser revalidates it, the server builds a weak ETag from the rules version, catalog version, last sync time, and stale flag. If the validator matches, it returns 304 before loading the catalog body. When a snapshot or its rules change, the client receives the updated catalog.

The cache contains shared card data, while each draw produces its own result. You can try the browser flow in the Extreme Demon Gacha pack simulator.

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.