Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

Our deployment id went from 6,052 mentions to 131 after a dependency bump, and no line of our code changed

On 2 November I wrote about a query string. Every asset URL on pub-trivia.app carried ?dpl= followed by a deployment id, and I counted it 6,052 times across 72 pages. The point of that post was that the id changes on eve

On 2 November I wrote about a query string. Every asset URL on pub-trivia.app carried ?dpl= followed by a deployment id, and I counted it 6,052 times across 72 pages. The point of that post was that the id changes on every deploy, so every deploy hands every returning visitor a cold cache for files that did not change.

On 30 November I committed a dependency bump: Next went from 16.2.7 to 16.4.6, along with the Radix, Sentry, Supabase and Stripe packages. It touched package.json, the lockfile, and a four-line addition to pnpm-workspace.yaml. It touched nothing under app/.

Today I fetched all 117 pages in the sitemap again and ran the same count. This post is the diff, and the part where I correct myself.

You can follow along on any page. Open pub-trivia.app/pricing, view source, and search for dpl=. I will tell you what you should find.

The numbers

Same method as before: curl --compressed on every URL in sitemap.xml, then a regex over the saved HTML. The earlier figures come from my two earlier posts, so the pages in scope differ (72 then, 117 now). I have used per-page figures where the page count matters.

                                   before                  2 Dec (117 pages)
?dpl= occurrences                  6,052 (72 pages, 2 Nov)  131
  per page                         about 84                 1.1
script tags with a src             2,258 (30 Nov)           2,372
inline script tags                 2,525 (30 Nov)           783
/pricing script tags               44 (30 Nov)              29
/pricing document bytes            102,010 (30 Nov)         95,321
distinct /_next/ paths in HTML     44 (30 Nov, all root-    38
                                   relative paths)

The 30 November figures come from the census I published that day, over the same 117 pages. So the script rows are a direct before and after, and the inline count dropped from 2,525 to 783, a fall of 69 per cent, while the external script count rose by 114.

Where do the 131 remaining dpl= occurrences live? 114 of them are the logo: /logo.svg?dpl=... in the header image, one per page. The other 17 are on the homepage, which carries 18 in total. The three legal pages, which get the compact footer and no header image, have none.

So the id has not gone away. It now appears only where the image component writes it, and nowhere that a script or stylesheet is referenced.

What the script URLs look like now

Here is how to see the new shape yourself:

curl -s https://pub-trivia.app/pricing | grep -o '/_next/static/immutable/chunks/[^"]*\.js' | head -3

Every one of the 37 static paths in the HTML now sits under /_next/static/immutable/, a folder name that did not exist in our output before. The chunk file names are short content hashes with no query string. Fetch one and read the headers:

curl -sI https://pub-trivia.app/_next/static/immutable/chunks/<one of the names above>

You get cache-control: public,max-age=31536000,immutable and an etag that is just the file's own path. The folder is named for the policy it carries.

I also repeated the experiment from the earlier post, asking for the same chunk three ways: bare, with ?dpl=nonsense, and with the real id. All three answered 200 with the same 28,850 bytes. The server ignores the query on these files, as it did before, but now the HTML does not bother sending it.

The logo is the opposite case. /logo.svg answers with cache-control: public, max-age=0, must-revalidate, with or without the query, so the one asset that still carries a deployment id is the one that revalidates on every visit regardless. That is a public/ file, not a build output, and the headers for it are a separate decision from anything in the bump.

What I claimed, and what I can now say

In the earlier post I wrote that the cost of the query string was one cold cache per deploy: 456 KB of JavaScript, correctly cached and then discarded because its URL changed. I can no longer say that about the current output, because the URL is now a function of the file's content rather than of the deployment.

But I have to be careful about what I have actually shown. I have shown the shape of the HTML and the headers on one deploy. I have not shown what happens on the next deploy, because there has not been one yet. The claim "unchanged chunks keep their URLs across deploys" follows from the names being content hashes, and it is the claim I would bet on, but it is a prediction until the second deploy exists. To make it checkable, here are three chunk names from today's /pricing:

14qlqcx-itjdn.js
0l6a80_l7i7xs.js
18b76hi3rltfx.js

After our next deploy, run the grep above again. If a name from this list is still there, the cold-cache cost is gone. If all three have changed, I was wrong and the hash includes something deploy-specific.

I also cannot tell you from outside that the bump is what changed the output. I can see that the HTML changed shape between 30 November and today and that the only commit in between is a dependency bump that moved Next across two minor versions. That is a strong correlation with one data point, and I have not diffed the two build outputs.

The inline scripts are the surprise

I expected the query string to move. I did not expect the inline <script> count to fall by 69 per cent.

On the 30 November census, the 117 pages carried 2,525 inline scripts between them, about 22 per page. Now they carry 783: 5 to 8 per page, with a median of 7. The external ones went up a little, from 2,258 to 2,372, so the page is not merely moving the same work around. The /pricing document lost 6,689 bytes (102,010 down to 95,321), about 6.6 per cent, and the whole set of 117 documents now totals 9,158,662 bytes, a median of 77,005 and a maximum of 157,868 (the homepage).

I do not know why. Inline scripts in this kind of page are how the framework streams its server-rendered payload into the document, and I would guess the new version batches them, but I have not read the changelog closely enough to say so, and a guess in a post is how the last correction came about. What I can say is that the number of places in our HTML where a script has to be parsed before it can be skipped is a third of what it was, and that I did nothing to cause it.

What did not change

Plenty stayed put, which is worth listing because "everything is faster" would be the wrong takeaway:

  • The link: rel=preload header for the two font files is still on the homepage response, with the same font paths now under the new folder.
  • The response headers we set in next.config.mjs (HSTS, nosniff, X-Frame-Options, the referrer and permissions policies) are all present and unchanged.
  • The HTML itself is still cache-control: private, no-cache, no-store, max-age=0, must-revalidate on the homepage, as it was.
  • There are still no iframes and no forms in the 117 documents.

Why this is the cheapest kind of win

The lesson I take from this is not about Next. A configuration that existed for the framework's own reasons (skew protection, in this case) cost us a measurable amount for a long time, and the fix arrived as a passenger on a maintenance commit. A dependency bump is a thing to measure on both sides: before and after, on every page, with the same script. If I had not rerun the census, I would still be telling people about a cold cache that no longer exists.

You can run the whole thing yourself in a few lines. Fetch https://pub-trivia.app/sitemap.xml, request each URL, and count dpl=, <script, and /_next/static/immutable/ in the saved HTML. The same pages are the ones you can browse: pricing, the free tools, and the FAQ are good places to start, and the whole site is on the PubTrivia homepage, which has a free tier that needs no card if you would like to try the product the pages describe.

If you find a chunk name that survives our next deploy, you have just confirmed the part of this post that I could only predict.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.