Skip to Content
Platform.Ontology

Cache Storage

A store of HTTP responses used by service workers to serve pages offline.

Works without askingFiles and storageIn sessionWeb browsersWhile you use itAfter you leave the site

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

BrowserStatusFirst versionReleasedNote
ChromeSupported432015-05-19None
EdgeSupported162017-10-17None
FirefoxSupported412015-09-22None
SafariSupported11.12018-04-12None
Safari on iPhoneSupported11.32018-03-29None
Chrome on AndroidSupported432015-05-27None
Samsung InternetSupported4.02016-03-11None

How a site asks for it

APIcaches.open(name).then(c => c.put(req, res))
Browser compat keysapi.CacheStorage
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)Yes
Needs a user gestureNo
How long it lastsUntil cleared or evicted. Safari 7 day cap applies
How to take it backClear site data, browser privacy settings
Inside an iframeNot listed

Data you get

What comes back: Cached responses
Shape: binary
How often: any time

FieldTypeUnitRangePrecision
quotaintegerpercent of disk10 to 60approximate

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

TypeExampleApps
gamesA browser game keeps its art and sound files here, so it starts fast and can run offline.None named
socialA social web app opens its shell at once and then loads new posts.Twitter Lite, Pinterest
shoppingA coffee or store web app lets you browse the menu without a connection.Starbucks
productivityA document or note app opens offline and syncs when you reconnect.Google Docs
mediaA music or podcast web app keeps pages and covers ready for a quick start.None named
newsA news site saves recent stories so you can read them in a tunnel.None named
travelA web boarding pass keeps working with no signal.None named

Risks

  • Stale copies
  • Uses storage space

What the platform says

Good uses and abuse

Legitimate uses

  • Offline pages, faster loads

Known abuse

  • Persisting tracker scripts on the device

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits0Rough identifying entropy, when known

History

  • 2023-07, Chrome 115: Partitioned in third party contexts
  • 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.

On this page