Public Cache vs. Private Cache
A public, or “shared” cache is used by more than one client. As such, it gives a greater performance gain and a much greater scalability gain, as a user may receive cached copies of representations without ever having obtained a copy directly from the origin server.
A private cache is only used by one client, only for the IP it was created for. Generally this applies only to a cache maintained by that client itself, though if you had a proxy that was only being used by one client it would be possible to configure it to act as a private cache. Private caches do not offer quite as much scalability as public caches, but they do have certain important advantages over public caches:
- They offer immense benefits to the user of that one client.
- Almost every client on the visible web (that is, browsers, RSS readers, and other interactive user agents) and a very large number of those on the machine-only parts of the web (that is, spiders and clients of web services) use a private cache of some sort. As such, you can rely upon the presence of at least one cache being involved in almost everything you do on the web.
- With some representations it may not be appropriate for public caches to cache them or to return those representations without re-validating them but perfectly acceptable for private caches to do so (e.g. anything which can only be seen by authorized users or which changes its representation depending upon who is looking at it). It can even be appropriate for encrypted documents to be so cached (though this requires one to be very sure as to the security of the cache itself, and so is generally not done).
When to use public cache, private cache, or no cache
- Infrequently changed
- Popular demand (requested frequently)
- Can only be used by one user/client, such as personal information on a web site (for authorized users)
- Resources such as documents only available for one particular user or authorized users.
- Resources served via the HTTPS protocol
- Responses with cookies
- POST request Dynamic content (such as time sensitive info)
- Frequently changed objects