--- title: Browser Cache description: "A copy of assets on the visitor's device. Correct Cache-Control speeds up repeat visits without serving stale files." canonical: https://penasihathosting.com/en/hosting-wiki/browser-cache type: wiki locale: en updated: 2026-10-29 author: Willya Randika --- # Browser Cache ## Overview - **Summary:** A copy of assets on the visitor's device. Correct Cache-Control speeds up repeat visits without serving stale files. - **Author:** Willya Randika ([profile](/penulis/willya-randika)) ## Article **Browser cache** is a copy of assets (CSS, JS, images, fonts) stored on the visitor's device. On a return visit, the browser can use the local copy without asking the server again. ## The headers that control it | Header | Role | | --- | --- | | `Cache-Control` | Main rule: `max-age`, `public`, `private`, `no-store` | | `Expires` | Legacy expiry time; some servers still send it | | `ETag` | File fingerprint for `If-None-Match` validation | | `Last-Modified` | Last change time for validation | A common example: ```http Cache-Control: public, max-age=31536000, immutable ``` Use it for assets whose filenames contain a hash (`app.3f9c2.js`). For HTML, use `no-cache` or a short `max-age` so changes appear quickly. ## Cache busting If the filename stays the same, the browser may keep using the old version. Change the filename during the build (`app.[hash].js`) or add a version query. Do not rely on `?v=1` for every asset without changing it on deploy. ## What to watch for - **Browser cache and CDN cache are different.** Each has its own rules. - **Do not cache old HTML.** Pages can show stale content after a deploy. - **Use `no-store` for sensitive data.** Do not put account pages in a public cache. - **Test after deploy.** A hard reload or Incognito helps confirm the new version. - **304 is a healthy response.** The browser uses its cache and the server saves bandwidth. Every deploy should produce new asset filenames. If HTML is cached too long, visitors can see links to old assets that no longer exist. Test in Incognito after deploy and keep HTML and static-asset Cache-Control policies separate. ## FAQ Yes, on repeat visits. Assets already stored do not need to be downloaded again. The browser is probably using its cache. Use hashed filenames for cache busting or a hard reload while testing. `no-cache` still stores a copy but must revalidate it. `no-store` does not store it at all and is stricter for sensitive data.