05-23-2011, 04:26 PM
Join Date: Oct 2010
|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. Reverse Proxies (gateway caches) and the vast majority of proxies are public caches.
A private cache is only used by one client. 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 (say you had a small LAN for your own use only and put a web proxy near the gateway) 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 webservices) 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 not to cache
- Can be shared by many users such as site logo, navigation images, js, css, etc.
- Change infrequently
- Popular demand (requested frequently)
- Can only be used by one user/client such as personal information on web site (for authorized user)
- Resource such as documents only available for one particular user or authorized user.
- Resource served via HTTPS protocol
- Response with cookie
- POST request
- Dynamic content (such as time sensitive info)
- Frequent changed objects