Http Caching strategies: Pages
These strategies applies to EPiServer CMS 5 R2, the setting httpCacheability does not exist in R1. Page caching in CMS is enabled by setting httpCacheExpiration in web.config, but remember that this setting has no effect on logged in users.
#1 Dynamic pages
So by default all pages are delivered as dynamic pages and will never be cached on either the client or on the server.
<siteSettings (....)
httpCacheExpiration="0:0:0"
httpCacheability="Public"
httpCacheVaryByCustom="path"
httpCacheVaryByParams="id,epslanguage"
(....)
/>
#2 Client cached pages
The httpCacheability is a new setting in R2 which allows you to control how caching is done, previously it defaulted to server side output caching only. By setting the value to Private we can force caching on the client only, meaning the httpCacheVaryBy settings can be ignored.
<siteSettings (....)
httpCacheExpiration="8:0:0"
httpCacheability="Private"
httpCacheVaryByCustom="path"
httpCacheVaryByParams="id,epslanguage"
(....)
/>
#3 Server+client cached pages
This approach will get you the real performance boost with both server and client caching. But you have to be very careful about the httpCacheVaryBy settings, if you have a page with a custom query string you have to add it to the list or customize the cache policy for that page type*. Remember that caching is only enabled for GET requests, never POST (for example postbacks). In this example I am setting the cacheability to Public but you could set it to Server or ServerAndPrivate if you need to exclude any upstream proxies.
<siteSettings (....)
httpCacheExpiration="8:0:0"
httpCacheability="Public"
httpCacheVaryByCustom="path"
httpCacheVaryByParams="id,epslanguage"
(....)
/>
*) If you need to customize the cache policy for some page types you need to override our method SetCachePolicy in your code-behind and implement your own handling.
13 October 2008