The Joy of Coding

February 25th, 2026 - Episode 431

Reminder - no plan survives breakfast.

Episode guide

Today

 

```HTML New Tab

```

Add a moz-newtab-cached protocol handler that can run in the privileged about content process.

It's job will be to get a remote stream from the parent for script, or for styles.

When the parent receives the request, the parent will get the hash value from prefs.
Will retrieve the cache entry for the particular resource - like, moz-newtab-cached://script.js - and check that the hash matches the expectation. If not, blow away all caches, fallback to streaming out the packaged script.

After retrieving the stream, kick off a DeferredTask that will eventually kick a check to see
if we need to refresh the cache. Once that fires, check RemoteSettings to see if the hash and/or
version has changed.

If the hash and/or version has changed, download them and stream them into the cache:

Writing to the cache. When it's time to write to the cache:

moz-newtab-cached protocol has one job: get a remote stream from the parent that will either pull from the valid cache entry OR will fallback to the built-in one. Which means that we have a bit of separation here:

moz-newtab-cached protocol handler is the "read-only" parts here. It just knows how to read from the cache. It does not know how to write to it. It knows how to fall back.

The other part is the business around noticing that a newtab loaded, and kicking off the DeferredTask to maybe write an update to the cache.

Rate this episode

Chat

Links

Glossary

Feedback