File sizes
How big is this file, before you download it?
A file's size is in the response headers, and you can read them without downloading
it. One Content-Length, returned by a request that asks for the headers
and no body. Foretaste makes that request when you hover a file link and prints the
number on the card beside it, so the size is on screen before you commit to the file.
Twelve links on a release page and one of them is the 900 MB one. Your browser will tell you which, about a second after you have started downloading it. There is a way to ask first, and it is not a setting somebody has hidden from you — the number genuinely is not on the page.
01
Why your browser cannot tell you
This is worth two sentences, because most of what is written about it assumes a setting exists somewhere. A page does not say how big its files are. A link is an address and some text; nothing in the markup carries the length of what is at the other end, and the site would have had to write the number in by hand for you to read it.
The size lives in a Content-Length header on the response — which means it
arrives with the download. That is exactly why the figure turns up in the downloads tray a
moment after the transfer starts: the browser is not withholding it, it has only just
been told.
So the question has a real answer and it costs a request. The only thing left to decide is who makes that request, and when.
02
Asking, on purpose
Right-click anywhere on the page and choose Find files on this page. Foretaste lists every file that page links to, grouped by kind, without fetching any of them — that list is a feature in its own right. Under it is a button reading Check the size of 12 files, or however many there are.
Press it, and the answers come back sorted into four bands:
- Under 1 MB
- 1 to 10 MB
- 10 to 100 MB
- Over 100 MB
Then you can show one band at a time. Bands rather than a number you type, because the question is never "which of these is over 18,400,000 bytes" — it is "which one is the big one", and four buckets answer that at a glance.
03
What asking costs
One HEAD request per file, four at a time, for the first 60 in the list. A HEAD asks a server for the headers it would send if you asked for the file, and for none of the file itself. The cost is a round trip rather than a download.
It is a button rather than something that happens when the list opens, and that is a deliberate trade rather than an oversight. A page of forty links would otherwise mean forty requests to somebody else's server, for files nobody has opened, every time you looked at a list. Four at a time is the same budget the picture thumbnails use, for the same reason: a scan list is nearly always one host, and thirty simultaneous requests to one host is indistinguishable from something rude.
Once a file has answered, the answer is kept for as long as that list is open. Filtering, re-sorting and filtering again does not send a second round.
The small card that appears beside a file link when you hover it does not do this. It shows only what the page already said, precisely so that moving a pointer across forty links cannot turn into forty requests. Sizes are the deliberate version of the same question.
04
When there is no answer
Some of them will not say, and that is common enough to expect rather than to treat as a
fault. A server can refuse a HEAD outright. It can answer and send no
Content-Length, which is normal for anything generated as it is sent. It can
refuse the request because it came from somewhere else. Or the file is simply gone.
All four look the same to a reader, so they are recorded the same way: nobody would say how big this one is. Two things Foretaste deliberately does not do with that answer:
- It does not retry with a GET. That would be downloading the file to find out how big the file is, which is the thing this exists to avoid.
- It does not guess. A server that sent the header with nothing in it has said nothing — reading that as zero would put the file in the wrong band and tell you it was empty.
A file with no answer is left out of every band rather than treated as small, so it never turns up in a band it does not belong to.
05
Knowing the size is usually not the goal
Worth saying, because it changes what you do next. Wanting the size is nearly always a proxy for wanting to know whether the file is worth the wait — and for a lot of formats you can answer that question directly instead.
- An archive can be read rather than measured. A ZIP keeps its index at the end, so the whole contents list comes back from a few kilobytes. How that works, and what it measured.
- A document can just be looked at. Right-click it and read it in a panel over the page. How to view a file without downloading it is the general version of that.
- A link with no filename can be identified. A size will not tell you what
attachment?id=8812is; the leading bytes will.
Sizes earn their place on the list that really is just a list — a release page, a directory index, a folder of exports — where every file is the same kind and the only thing separating them is how long each one will take.
All of this is free. What is free and what is Pro sets out the line; asking how big something is has never been on the paid side of it.
The questions people ask
Can you check a file size before downloading it?
Not from the page itself, because a page does not carry the sizes of the files it links to. The size arrives in a response header, so finding it out means asking the server that holds the file. Foretaste asks with a HEAD request, which requests the headers and no body, and it does it when you press a button rather than every time you open a list.
Why does my browser not show the size before the download starts?
Because the browser has not asked yet. It learns the size from the Content-Length header of the response it is already downloading, which is why the figure appears in the downloads tray a moment after the transfer begins rather than before you click. Nothing in the link itself carries it.
How does Foretaste find out how big a file is?
One HEAD request per file, four at a time, for the first 60 files in the list. A HEAD asks a server for the headers it would send and no body at all, so the cost is a round trip rather than the file. The answers are kept for as long as the list is open, so filtering and re-sorting does not ask again.
What happens when the server will not say?
That file is recorded as one nobody would say the size of. Some servers refuse a HEAD, some answer without a Content-Length, and some are simply gone. Foretaste does not retry with a GET, because retrying would mean downloading the file to find out how big it is, which is the thing this exists to avoid, and it does not guess: a header sent empty is treated as no answer rather than as zero bytes.