DEV Community

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

Posted on 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.

Top comments (0)