1. Tuntau
  2. Learn
  3. .sola format

The .sola page format

A .sola file is a web page with the parsing already done: the DOM tree, the style sheets and precompiled code, Horizon-compressed. Sola loads it without running its HTML, CSS or JavaScript parsers.

Format 1.1Preview: may still change
On this page
  1. Why a page format
  2. What it gains
  3. File layout
    1. Versioning
    2. Header flags
    3. Section codecs
  4. Sections
  5. Streaming
  6. Signatures
  7. Updates as deltas
  8. Compiling with solac
  9. Safety limits

Preview. .sola is still in development and can change between versions. Readers skip sections they don't know, so files keep loading across minor versions.

Why a page format

Every visit to an ordinary web page repeats the same work: parse the HTML, parse every style sheet, parse and translate every script. A .sola file ships the result of that work. solac compiles a page once; the browser decodes it straight into the DOM.

It is served as a normal content type, application/sola, negotiated with Accept (Sola sends application/sola;q=0.95). So one URL can serve HTML to every browser and .sola to Sola.

What it gains

Measured on a large production Angular app (6.6 MB of minified JavaScript) over a 10 Mbit/s, 50 ms link:

What it gains
Bytes by load endFirst visitRepeat visit
HTML + Brotli 111.41 MB2094 ms782 ms
.sola (default)0.91 MB1417 ms643 ms
  • First paint after about 30 KB of a multi-megabyte file.
  • A repeat visit to an unchanged page: one request of 51 bytes.
  • After a deploy that changed one component: 137 KB, against 1.45 MB for HTML + gzip.

File layout

Header and table integers are little-endian. Inside sections, integers are LEB128 varints and strings are length-prefixed UTF-8.

header   32 bytes   magic "SOLA\r\n\x1a\n" (8) | u16 major | u16 minor | u32 flags
                    | u32 section count | 12 reserved bytes
table    40 bytes   per section: u32 id | u32 codec | u64 offset | u64 stored length
                    | u64 raw length | u32 CRC-32 of the raw bytes | u32 reserved
sections            back to back at their offsets
digest   32 bytes   SHA-256 of everything before it (also the HTTP ETag)

Versioning

The current version is 1.1. Readers skip unknown section ids. A new section is a minor version; a change to an existing section is a major version.

Header flags

Header flags
BitNameMeaning
1STREAMSections are in streaming order, HASHES first.
2SPLITSome sections live in separate files (EXTERNAL).
4SIGNEDThe file carries a SIG section.

Section codecs

Section codecs
CodecMeaning
0raw
1one Horizon stream at the web level (built-in web dictionary)
2chunked: parts over 256 KB cut by content into 16–256 KB chunks, each raw, hz, or hz primed by the previous four chunks
3primed: hz coded after the last 1 MB of earlier sections of its group (tree parts)

Sections

Sections
IdSectionContent
1METAkey/value strings: source, title, generator, versions
2STRINGSdeduplicated string table: tags, attributes, text
3TREEpre-order node stream (elements, text, comments, doctype; shadow roots inline)
4STYLESper style sheet: hash, length, rules in binary form
5SCRIPTSper script: source hash, kind, strict mode, precompiled code
6ASSETSsame-origin resources: URL relative to the page, MIME type, body
7SOURCEoptional original HTML (fallback)
8HASHESfirst in 1.1: per section its codec, lengths, CRC-32 and SHA-256
9ASSETS_LATEimages, video, audio
10SIGoptional Ed25519 signature
11EXTERNALsections stored in separate .solas files: (id, URL)
12ASSET_URLSthe URLs the file carries, so other requests aren't held back
13BLOB_INDEXper blob: key, codec, lengths, CRC-32, offset, SHA-256
14SCRIPT_URLSscripts whose source is in LAZY
15LAZYsources and stack positions, fetched blob by blob with HTTP Range
256 + ktree part kcontinuation of the node stream (up to 40 parts)

Container sections (SCRIPTS, ASSETS, ASSETS_LATE, LAZY) are stored raw with a packed index. Each blob is compressed on its own, and only if that makes it smaller, so images and fonts stay as they are.

Streaming

With the STREAM flag, sections come in this order, so the browser can paint the head before the rest arrives:

HASHES  SIG?  EXTERNAL?  META  ASSET_URLS  SCRIPT_URLS?  BLOB_INDEX  STRINGS  TREE  STYLES
                                                              (the head: enough to paint)
tree parts...  ASSETS  ASSETS_LATE  SCRIPTS  SOURCE?  LAZY?  digest

Every resource is used as soon as its own bytes match their SHA-256. With --split, big sections go to content-addressed files (_sola/<kind>-<sha256>.solas) that can be cached forever and are never fetched twice.

Signatures

A file can be signed with Ed25519 over its section hashes. The signed message is:

"sola-signature-v1\0" origin "\0" key-id "\0" signed-at (u64 LE) SHA-256(HASHES section)

Public keys are published at /.well-known/sola-keys:

{"keys":[{"id":"k1","alg":"Ed25519","key":"<base64url>"}]}

Updates as deltas

Sola supports Compression Dictionary Transport (RFC 9842): the previous version of a page is the dictionary for the next. Besides Brotli deltas (dcb) there is an hz variant, dch: magic FF 44 43 48, the dictionary's SHA-256, version 1, then long copies from the dictionary and the remaining literals as one hz stream.

Compiling with solac

solac loads a page once, headless, and records what the engine parsed: the DOM before scripts run, every style sheet, the code of each script and all same-origin resources. The page behaves exactly as the source: same script order, same events, same stack-trace positions.

solac page.html -o page.sola               # one page
solac site/ -o out/ --split                # a folder, big sections as separate files
solac http://localhost:8080/ -o index.sola # a running dev server
solac --code startup|full|none             # how much code to precompile (default: startup)
solac --embed-source                       # keep the HTML as a fallback
solac --info page.sola                     # what's inside
solac keygen -o site                       # signing keys
solac sign page.sola --key site.key --origin https://example.org
solac delta old.sola new.sola -o new.dch   # a delta between versions

With the default --code startup, only functions that ran while recording are precompiled; the rest compile from source on their first call.

Safety limits

Readers treat every .sola file as untrusted. Sola's reader caps a file at 512 MB, a decoded section at 256 MB, all decoded data at 1 GB, 64 sections, 4 million nodes and a tree depth of 4096. Precompiled code goes through a verifier before it runs, and a script whose code fails the checks is compiled from its source instead. Malformed input is an error, never a crash.