It is my understanding that there are various different caches in Sitecore.
What are they for?
I know there is an item cache, a html cache and a prefetch cache, but I don't understand how they differ or how I can control these caches
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.
Sign up to join this communityPrefetch cache
This is item data pulled out from the database when the site starts up - from the Sitecore docs:
"Each database prefetch cache entry represents an item in a database. Database prefetch cache entries include all field values for all versions of that item, and information about the parent and children of the item.
Populating the prefetch cache results in smoother user experiences immediately after application restarts. Excessive use of prefetch caches can affect the time required for application initialization."
Data cache
This cache is to minimise the round trips to the database, it again pulls item information from Sitecore but the difference being it does it when the item is requested (rather than start-up of the site); it will pull the data from the pre-fetch cache if it's there or go back to the database if not.
Item cache
This cache has objects of type Sitecore.Data.Items.Item which would be used in code; when an item is requested in code it will look in the Item cache, then back up the data cache and up again to pre fetch cache and finally to the database.
HTML cache
This output caches the HTML from sublayouts and renderings, there are a nice level of configuration to only cache the HTML based on querystrings, different data etc.
Flow of cache
The following is taken from http://learnsitecore.cmsuniverse.net/Developers/Articles/2009/07/CachingOverview.aspx
References
Some of these references are a bit old, but I don't believe this part of Sitecore has changed that much over the years.
Here you can find detailed info about cache. In essence:
prefetch
Database prefetch caches contain items that Sitecore accesses during and immediately after initialization, and items with children that Sitecore often accesses as a group. Sitecore populates database prefetch caches at application initialization, and maintains those caches over the life of the application. Each database prefetch cache stores data from a different database or data source. Not all data providers implement prefetch caches.
item
Database item caches store items. Database item caches are dependent on database data caches, which operate at a lower level. Each entry in a database item cache represents a single version of an item in a single language. Sitecore does not pre-populate database item caches.
HTML
The HTML cache (also known as the output cache) associated with each managed Web site contains the output generated by individual renderings under different conditions. Each site HTML (output) cache is dependent on the database item cache.