r/javascript • • Nov 01 '26

I built a client-side cache in Rust and compiled it to WebAssembly

https://blaze-cache.github.io/docs

Hey everyone,

I built **Blaze Cache**, a client-side caching library written in Rust and compiled to WebAssembly.

The main idea was to get a fast, predictable cache in the browser with:

- Synchronous get/set after initialization (no Promises on the hot path)

- SIEVE eviction

- TTL + tag-based invalidation

- Optional IndexedDB persistence

- Adapters for Axios, fetch, TanStack Query, and SWR

I was mostly curious whether moving the cache core into Wasm would help with performance and structure compared to typical JS cache implementations.

Would love feedback from people who’ve worked on caching, Wasm, or frontend performance.

GitHub: https://github.com/blaze-cache/blaze-cache

Docs: https://blaze-cache.github.io/docs/

0 Upvotes

7 comments sorted by

2

u/Ronin-s_Spirit Nov 01 '26

Does that not defeat the purpose of using Rust?

1

u/Brave_Magician2474 Nov 01 '26

Not really, the goal isn’t to avoid JavaScript, it’s to keep the cache engine itself in a more predictable systems language.

Rust/Wasm runs the hot path (storage, eviction, TTL, tags). JS handles browser integration and adapters. So it’s closer to “native core + thin JS layer” than replacing JS entirely.

2

u/Ronin-s_Spirit Nov 02 '26

I wonder if Rusts promises break (types and all the memory safety bells and whisltes), a Rust-to-Rust ABI would be reliable but a Rust-in-the-browser scenario is not clear to me.

1

u/Brave_Magician2474 Nov 03 '26

Fair point.

Rust’s memory safety guarantees still apply "inside" the Wasm module. The core is still normal safe Rust: ownership, borrowing, no data races in the cache engine itself, etc.

What changes in the browser is the boundary:

- JS can pass weird inputs across the Wasm boundary

- You no longer have a pure Rust-to-Rust ABI for the public API

- So validation still matters at the edge

In practice:

- Inside Wasm: Rust safety model holds

- Outside Wasm: JS is still JS

- The "unsafe" part is mostly at the interop boundary, not in the cache engine itself

So it’s not the same as a pure Rust-to-Rust system, but the core engine still gets the predictability and safety benefits of Rust. The browser just becomes the host environment around it.

1

u/JcerParreno21 Nov 03 '26

If you have to serialize on every read and write it definitely does

1

u/AutoModerator Nov 01 '26

Project Page (?): https://github.com/blaze-cache/docs

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/rcindy1 4d ago

A useful comparison is end-to-end cache hits with realistic values; timing the Rust core alone can miss JS/Wasm boundary and value-conversion costs.