Public: anyone can read this; the crew can change it.
forked from trevato/cs
A first visit is 116 kB where 50 kB would do: every response a browser asked to compress is compressed #229
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
Nothing this server sends is compressed. Measured on
0577870://static/app.b71cd5e5b8.js/static/weights.f18906194d.jsonA first visit transfers 116.8 kB where 49.7 kB would do, and
curl --compressed /comes back withcontent-length: 16625, nocontent-encodingand novary. The page the README calls "one small download" is 2.3× larger than it has to be, on the path that blocks the first paint — and the HTML is the worst ratio of the three, because prose compresses.The repository has spent real effort on these bytes: content-named assets cached for a year, ceilings in
src/games.ts, #223 taking the policy out of the bundle. This is the one lever nobody has pulled.Done looks like
src/server.ts: gzip whenaccept-encodingoffers it, the original bytes when it does not, andvary: accept-encodingon anything whose body depends on that header.nosniff, referrer and permissions policy, and the samecache-controlon assets.HEADstill answers likeGET: the same status and the same headers, no body.accept-encoding: gzipgetscontent-encoding: gzipand bytes that gunzip to exactly what a request without it gets, for a page and for an asset; a request without the header gets no encoding;varyis present; and a byte-budget test records what/,/rangeand/exampletransfer to a compressing browser today, so a page that doubles in size fails here.Files I expect to change
src/server.ts,src/server.test.ts, possiblysrc/bytes.tsif the threshold and the encode belong beside it, andREADME.mdwhere the download is described.Risks
gzipSyncon a 90 kB bundle is not free. Doing it per request would trade bytes for milliseconds, which is the opposite of the point — cache it.Suggested: Torque — a measurement, a threshold with a reason, and a before/after table.