Cache Storage
A store of HTTP responses used by service workers to serve pages offline.
In one line
Can keep copies of pages and files so the site opens without internet
A store of HTTP responses used by service workers to serve pages offline.
Lets a site keep its own pages, scripts and API responses on the device. Shares the origin quota with IndexedDB. Opaque cross-origin responses are padded in quota accounting so sites cannot probe sizes.
What it can and can't do
What the user does: Nothing. It happens when you visit or install the site.
It can
- Save pages, images and data for later
- Serve them when you are offline
- Speed up repeat visits
It cannot
- Be seen by other sites
- Keep data for ever, since the browser may delete it when disk space is low
- Hold more than the site's storage limit
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 43 | 2015-05-19 | None |
| Edge | Supported | 16 | 2017-10-17 | None |
| Firefox | Supported | 41 | 2015-09-22 | None |
| Safari | Supported | 11.1 | 2018-04-12 | None |
| Safari on iPhone | Supported | 11.3 | 2018-03-29 | None |
| Chrome on Android | Supported | 43 | 2015-05-27 | None |
| Samsung Internet | Supported | 4.0 | 2016-03-11 | None |
How a site asks for it
| API | caches.open(name).then(c => c.put(req, res)) |
| Browser compat keys | api.CacheStorage |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | No |
| How long it lasts | Until cleared or evicted. Safari 7 day cap applies |
| How to take it back | Clear site data, browser privacy settings |
| Inside an iframe | Not listed |
Data you get
What comes back: Cached responses
Shape: binary
How often: any time
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
quota | integer | percent of disk | 10 to 60 | approximate |
Technical limits
- Same origin quota as IndexedDB
- Needs secure context
- Opaque responses are padded (Chrome pads to about 7 MB each in quota accounting)
- Not shared across origins
The story
What it is
A store of web responses that lets a site work offline and load fast.
For you
You never see it. It is why a web app opens quickly even on a bad connection, and why some pages still work on a plane.
For makers
Makers use it to make web apps feel like phone apps. Fast starts keep people from leaving. It also uses your storage space and can hold old copies of a site.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A browser game keeps its art and sound files here, so it starts fast and can run offline. | None named |
| social | A social web app opens its shell at once and then loads new posts. | Twitter Lite, Pinterest |
| shopping | A coffee or store web app lets you browse the menu without a connection. | Starbucks |
| productivity | A document or note app opens offline and syncs when you reconnect. | Google Docs |
| media | A music or podcast web app keeps pages and covers ready for a quick start. | None named |
| news | A news site saves recent stories so you can read them in a tunnel. | None named |
| travel | A web boarding pass keeps working with no signal. | None named |
Risks
- Stale copies
- Uses storage space
What the platform says
- web.dev: Service workers and caching. Google pitches caching with service workers so web apps load fast and work without a connection.
- MDN: CacheStorage. Documents the store pages use to keep copies of web files for offline use.
Good uses and abuse
Legitimate uses
- Offline pages, faster loads
Known abuse
- Persisting tracker scripts on the device
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 2 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 0 | Rough identifying entropy, when known |
History
- 2023-07, Chrome 115: Partitioned in third party contexts
Related capabilities
Related
- IndexedDB. Can keep gigabytes of organized data for its own site in your browser
- Service worker lifetime. Can keep a background helper script for a site that stays after you close the tab
Sources
How well checked: Based on official documentation.