
Recent past blessed me with an interesting experience at workplace. Though I am a little late in penning it down, but I had resolved to do so during those very days. In Internet industry presentation remains the foremost area of concern. Broadly speaking presentation includes concept, aesthetics, accessibility and the delivery. Of course all these are supposed to revolve around some content. But it is the delivery that enables all the rest to happen.
To speed up the user experience on visiting a website numerous caching techniques are employed. With reference to client-server architecture figure above, I will try to enumerate some.
Server Cache: These are the caching techniques employed by the hosting site primarily to optimize server performance. Not only are they the only ones on which the site host can rely on, they are also the only things he can control. Broadly, they can be hierarchically listed as -
- Data cache - The very first level of cache happens at the data hosting platform. Be it a database like MySQL, Oracle or search platform like FAST, same data fetch queries are cache with their respective results to avoid redundant queries.
- Object cache - This comes one level above data cache. The objects created out of the fetched data are cached to avoid data fetch in subsequent accesses to the same object.
- Script cache - The script compiling the object can also be pre-compiled with run time data saved in-memory. This is to save the compilation time in scenarios of bulky scripting.
- Markup cache - The renderable markup generated by the server side scripts need not be generated again and again for the same resource request. The ready to dispatch HTML is cached to avoid redundant processing.
- Image/Styles cache - Resources other than the HTML viz images and style sheets rendered by the site are usually static in nature. Disk drive reads being the slowest of all operations, these resources may again be contained in memory to be dispatch as requested.
Network Cache: Next to server comes the network. Caching employed here primarily to optimize the network bandwidth. Generally, here there are two hooks for caching -
- Reverse Proxy cache: The server gateway may, at its turn, try to reduce internal traffic by caching URLs hit once. The requests are served externally.
- Proxy cache: The client gateway again may try to optimize the bandwidth consumption by caching the pages already visited by internal users. The URL request in this case is served internally.
- Script cache - Client application, usually the browser, caches the client side scripts to avoid redundant fetches.
- Markup cache - The markup(HTML) to be rendered is cached.
- Image/Styles cache - Browser caches the images and styles.
Having identified the various methods to cache we should keep few key things in mind -
- Update frequency of cached entity
- Cache refresh rate
- Refresh through
- Cache fetch latency Vs actual fetch latency
- Percentage entity load time improvement
- Percentage overall load time improvement
- Fast Vs Fresh
- Stale appetite