The most embarrassing bug report I ever got went like this: I fixed a bug, deployed it, tested it myself, and the visitor still saw the broken version. The new file was on the server. My own browser showed the fix. Then I talked the visitor through clearing their cache, and suddenly everything worked.
The bug was never in my code. It was in the browser cache, and it taught me the cheapest lesson in web performance: browsers remember your files far longer than you expect, and you have to give them a reason to forget.
Why the browser holds on so tightly
When a browser downloads style.css or app.js , it keeps a copy. The next time it needs that file, it checks its cache first. If the server sent a far-future Cache-Control header like max-age=31536000 , the browser may not even ask the server whether the file changed. It just serves the old copy, silently, for a year.
That is exactly what you want for performance. A returning visitor should not re-download files that have not changed.β¦