Server Side Caching
Introduction
Caching is server side technique to substantially improve performance serving the content, which otherwise don't change frequently. In that case the web presentation of content doesn't need to be generated at every request but should be rather served from the cache. Cache is then refreshed when a preset timeout occurs. Or it is invalidated manually.
Usage
- Object aidaCacheView: aSymbol on: aSession
- if true, then this object's view will be globally cached in site's cache
- Object aidaCacheTimeout
- how many seconds this object is globally cached in site's global cache
- nil = global default, set in site's global cache settings
- site cache cacheTimeout: aSeconds
- in seconds, how long cache entry lives until is invalidated
- site cache invalidateObject: anObject
- if exist then cache entries for that object are not valid anymore and shall be refreshed
Advices
Caching has side effects, so it must be used carefully. First, during the valid cache period the content cannot be refreshed from the browser but only programatically
- set the cache timeout per object or on site's cache appropriately. By default is one day but if your content changes frequently, set it lower. Sometimes even few seconds already speedup the site a lot.
- don't cache views which have a dynamic content (for example: statistics of a webpage)
- don't put a dynamic components on views to be cached (like showing the current time)
- don't cache for administrators.
Example
WebAdmin, for view #login, but by default commented off. Used for benchmarking cached vs. generated responses.
WebAdmin>>aidaCacheView: aSymbol on: aSession
^aSymbol = #login
Development notes
WebCache
- parent objects settings other
WebCacheEntry