A file on disk ≠ a served page
You uploaded the new file, the size is right — and the site still shows the old page. A file on disk is not the same as the page someone actually serves. Between the two sit layers: browser cache, service worker, CDN, web server, routing. This lesson is how to find which layer is answering — with numbers and headers, not by eye.
Cache-Control and ETag, wrong docroot, symlinks, service workers and curl -I were added. Commands were checked against the official documentation; the curl and local python3 -m http.server part was really run (see "Try it yourself").01What you'll learn
- To think of a request's path as a chain of layers — and to ask which layer is answering.
- To compare "what is on disk" with "what is served" numerically, and to read headers with
curl -I. - How
Cache-Control,ETagand a 304 response work — and why "may be stored" is not the same as "may be used without asking". - The most common causes: browser, CDN or server cache; a wrong docroot; a symlink; a service worker; a page embedded in code.
- How to touch a live server without breaking it: a backup, a configuration check, reversibility.
02Before you start
- A terminal with
curl(Linux, macOS or Windows 10+). - Access to the site's files and — if it is yours — to the web server configuration (nginx or Apache).
- A page that "won't update", or readiness to run the demo from step 7 on your own machine.
- The examples use
https://example.com/and/path/to/site/— replace them with your own.
03Steps
-
Check first, act second — and the number that splits the hypotheses
The first hypothesis is the obvious one: "the file never arrived". You check it before acting on it.
ls -lashows the file at the right size — the hypothesis falls and you waste no effort. Do not "fix" a file just to see whether the problem is there, if a check has already said it is not.The second check must split the hypotheses, not merely confirm one. Compare the size of the file with the size of what the server returns:
bash · disk vs served# how many bytes the file on disk is wc -c < /path/to/site/index.html # how many bytes the server returns (replace the address) curl -s https://example.com/ | wc -cThe two numbers differ? The server is serving different content. In our case (13.09.2026) the file was 4,977,695 bytes while the address returned 11,788 — so different that the question closed at once. A
grep -cfor a marker would not have split it: it returns 0 under both hypotheses.✅RuleUse a check that tells "old" from "new" by a number or a heading. A check that returns the same under every hypothesis solves nothing.⚠️Keep the check marker ASCIIIf you check for a string, search for a Latin-script string that exists only in the new file (e.g. a function name). In our case a Cyrillic search through the terminal went through the console codepage and "lied" without an error. Move Cyrillic text as a file (e.g.scp), never piped through a terminal.⚠️Dynamic pagesIf the page contains a date, a session identifier or an ad, the sizes will not match to the byte even when the answer is "right". Then compare something stable — a title, a version, a marker string. -
Ask the server:
curl -Icurl -I(--head) asks for the headers only: for HTTP this is a HEAD request and returns just the response headers. So you see what the server says without the browser getting in the way —curlhas no cache of its own and no service worker.bash · the headerscurl -sI https://example.com/ # the whole GET with request and response headers, no body: curl -sv -o /dev/null https://example.com/What to look for:
Header What it tells you Last-Modifiedwhen the server thinks the file changed — older than your change? The server is serving another file ETaga fingerprint of the version; the same ETag after your change means the same old version is answering Cache-Controlhow long the response may be used without asking Agehow many seconds the response has sat in an intermediate cache — a big number means a cache (CDN or proxy) is answering, not the origin 🧪Tested locallyThe plainpython3 -m http.serverreturnsLast-Modifiedbut sends neitherETagnorCache-Control(we saw it in the response). A missingCache-Controldoes not mean "no caching" — see step 4. -
The layers between you and the file
A request passes through a chain. The old content can come from any link:
Layer How you recognise it How you bypass it Browser cache curlreturns the new page, the browser the old oneforce a reload; DevTools → Network has "Disable cache" ⚠️ not verified here Service worker the browser shows the old page even with the browser cache empty; curlreturns the new oneDevTools → Application → Service Workers: Update on reload, Bypass for network, Unregister; "Clear storage" removes the registration and all caches in one click CDN / reverse proxy a large Age;curlto the public address returns old, to the origin returns newpurge in the provider's panel ⚠️ the steps differ per vendor Web server (cache or configuration) curlstraight to the server returns oldcheck the configuration; nginx -T/httpd -S; reload after testingRouting / docroot the file is on disk but nobody reads it step 5 The working order:
curlto the address first. It returns the new page while the browser shows the old one → the problem is on the client side (browser cache or service worker). It returns old → the problem is upstream (CDN, server, docroot). -
Cache-Control,ETagand 304Three facts that save hours (per the MDN documentation):
- Without
Cache-Controlthings are still cached. A cache may store and reuse a response heuristically — for example based onLast-Modified. So "I set nothing" does not mean "no cache". no-cachedoes not mean "do not store". The response may be stored, but is not reused without revalidation with the server. For "do not store at all" useno-store— and it does not delete a response that is already stored.- Validation is a conditional request:
If-None-Matchwith anETag, orIf-Modified-SincewithLast-Modified. Unchanged →304 Not Modifiedwith no body; changed →200with the new content.
bash · conditional request (replace the value)# take the Last-Modified value from curl -I and send it back: curl -sI -H "If-Modified-Since: Thu, 01 Oct 2026 01:03:50 GMT" https://example.com/ # or by ETag (with the quotes, exactly as the server returned it): curl -sI -H 'If-None-Match: "33a64df5"' https://example.com/If it returns
HTTP … 304 Not Modified, the server confirms the resource is unchanged. We saw this in the local demo.✅For pages that change oftenCache-Control: no-cachetogether withETagandLast-Modified: the client always asks, gets a 200 when something changed and a 304 when not. No "old" content, and no needless bytes. - Without
-
Wrong docroot, virtual host, and a page embedded in code
The sneakiest case: you do everything right, but the server reads from another folder. nginx takes the root from the
rootdirective (defaultroot html;); in Apache it isDocumentRootin the virtual host. Do not guess — read the configuration:bash · where the server reads from# nginx: test and print the effective configuration nginx -T | grep -nE "server_name|root " # Apache: the virtual host settings httpd -Snginx -Tis like-t(checks the syntax and tries to open the referenced files) but also dumps the configuration.httpd -Sshows the virtual host settings as parsed from the configuration.⛔The page lives in code, not on diskIn our case the page was a string embedded in the server file itself — the route for/returned it and never read the disk. Overwriting the file changed nothing: nobody opens it. The sign: reading the routing (grep -non the server code) shows a constant, not a file read.Two fixes: A — embed the new text in the code again (works, but every change means rewriting code); B — add a route that serves
.htmlfrom a folder (reversible, and it removes the whole class of problem). B wins. In the new route, validate the filename with an exact-match pattern that allows no slash, so nobody can climb out of the folder. -
Symlinks
If the path to the file is a symlink, it may point at an old folder. See where it leads:
bash · symlinksls -l /path/to/site/ # lines with "->" are symlinks; the target follows the arrowIn nginx the
disable_symlinksdirective isoffby default; withonorif_not_ownerfollowing symlinks is restricted. In the local demopython3 -m http.serverfollowed a symlink to a file outside its folder and returned its content. Apache'sFollowSymLinksand the cache behaviour on network file systems (sendfile) ⚠️ were not verified here — read the documentation for your version. -
Try it yourself (local, 2 minutes)
A safe demo on your own machine — two folders, an "old" and a "new" one. The server reads the old one; you edit the new one and see that nothing changes.
bash · local demomkdir -p demo/old demo/new echo "OLD page" > demo/old/index.html echo "NEW page (edited)" > demo/new/index.html cd demo/old python3 -m http.server 8765 --bind 127.0.0.1 & sleep 1 curl -s http://127.0.0.1:8765/index.html # OLD page — the "new" file is not served curl -sI http://127.0.0.1:8765/index.html # Last-Modified, no ETag, no Cache-Control ln -s ../new/index.html linked.html curl -s http://127.0.0.1:8765/linked.html # NEW page (edited) — through the symlink kill %1 # stop the demo server🧪What we saw when we ran it (01.10.2026)The file in "new" was edited andcurlreturned "OLD page" — the file on disk is not the served page.curl -IshowedLast-Modifiedand nothing forETag/Cache-Control; a conditional request withIf-Modified-Sincereturned304 Not Modified; through the symlink we got "NEW page (edited)". Run in an isolated environment with Python 3 and curl. -
Before you touch a live server
- A dated backup of the file you are about to change, e.g.
cp -p index.html index.html.$(date +%Y%m%d-%H%M%S).bak. In our case the backups did double duty: they showed that an earlier session had already uploaded the same file (two files of the same size with an old date). - Idempotency: a code patch leaves a marker and, when run again, exits without changing anything.
- Syntax before writing: if you change server code, check the new content (compile it in memory) before writing it — a live server is never left with a syntax error.
- Test the configuration first:
nginx -torapachectl configtest(prints Syntax OK or the error). Only then reload:nginx -s reloadorapachectl graceful. Never restart before the checks. - Only reversible, precisely targeted changes: if the expected line is missing, the change refuses and changes nothing.
- A numeric check at the end: the new address returns the size of the new file; the old one stays as it was.
✅The final testTwo numbers and the question is closed: the served size equals the size of the new file. Not "it looks like the new one", but equality by number or by a marker string. - A dated backup of the file you are about to change, e.g.
04Check
1. The file on disk is right, but the site shows the old page. What is the best first check?
2. What does Cache-Control: no-cache mean?
3. A request with If-Modified-Since returns 304 Not Modified. What does that mean?
4. The page is embedded as a string in the server's code. Which of these does NOT help?
05What's next
06Sources
- MDN: HTTP caching — heuristic caching,
no-cachevsno-store, validation withETagandIf-Modified-Since, 304. - curl: manual —
-I/--head. - nginx: command-line parameters —
-t,-T,-s reload. - nginx: ngx_http_core_module —
root,disable_symlinks. - Apache: apachectl —
configtest,graceful. - Apache: httpd —
-S,-t. - Chrome DevTools: service workers — Update on reload, Bypass for network, Unregister, Clear storage.
- KAGAMI's own case from 13.09.2026 (generalised) and a local demo with
python3 -m http.server, run on 01.10.2026.