
The Internet Server Cache (see also ICM Server-Cache) allows you to considerably increase the performance and scalability of your BSP application. The ICM server cache provides a dynamic and active content caching technology, resulting in the following advantages for developing BSPs:
The resources required for creating BSPs are reduced.
You do not have to repeatedly execute BSPs that are frequently requested.
The possible performance improvements can be up to factor 20.
Performance and Scalability
Benchmarking tests for cache hits in the main memory have resulted in latent response times of less than one millisecond per request, and a total run of under 3,000 requests per second on a 4 CPU hardware.
These results are based on a strong parallel and multi-threaded architecture that supports simultaneous read and write accesses with versioning. Furthermore, a patented indexing algorithm is used to access the cache directory quickly. This algorithm is particularly suitable for long Web URLs as cache keys.
The features and the architecture of the ICM server cache are described in Internet Server Cache.
You have the following options to control BSP caching:
In the Web Application Builder (Transaction SE80), you can set the following properties for caching on the Properties tab page:
Expiry date for caching in the Internet server cache
Expiry date for caching in the browser (client-side)
Flag whether page caching should be browser-dependent
In your BSP application, you can control the behavior of the ICM server cache using response object method calls.
The following section describes how you should proceed.
Settings Caching Properties in the Web Application Builder
You can set the caching properties for the page on the Properties tab page of a BSP:

For both the browser cache and the ICM server cache, you can determine how long the page should be held in the cache. If you do not make any entries here, the cache in question will not be used for the page. Set the Browser-Dependent flag if you want the ICM server cache to fetch the page from the cache only if the request comes from the same browser type. If you do not set the flag, note that all of the elements used by the page must be non browser-dependent.
Note that when you use the browser cache, the client cannot tell when a page has changed. If the URL is the same, it always returns the same page from the cache until the expiry date has passed. If you use the ICM server cache, by using the invalidation methods you can ensure that the page stored in the cache is up to date.
Setting Caching Properties Using Method Calls in the BSP
You have several options here. In addition to the relative expiry date and browser-dependency, you can specify a final expiry date and invalidate cache entries. You can also activate caching not just for the page in general, but also according to user input.
Set the expiry time for an HTTP response with the methods of class CL_HTTP_RESPONSE (see also IF_HTTP_RESPONSE and IF_HTTP_REQUEST):
SERVER_CACHE_EXPIRE_ABS
SERVER_CACHE_EXPIRE_REL
Use appropriate automatic expiry times. For example, a banner displaying stock market tickers is updated every n minutes, whereas a product catalog should be updated only every n days or weeks.
You refresh (invalidate) objects asynchronously using the methods of class CL_HTTP_SERVER (see also IF_HTTP_SERVER):
You can use method SERVER_CACHE_INVALIDATE() to invalidate an individual object that can be identified by the following data:
Complete name, that is, URI path, form fields and BSP application context
Prefix of the name (hierarchical wildcards)
E-tag, that is, the entity tag and the unique ID that was assigned at the time of creation
You can use method SERVER_CACHE_INVALIDATE_LIST()to invalidate a list of objects (internal tables).
The system automatically forwards this data to other application servers, thus ensuring cache integrity.
You should avoid too frequent invalidations, so that system-wide transfers to other application servers are avoided.
You can find a simple example in the system in BSP application TUTORIAL_4, BSP results.htm in the event handler OnInitialization:
* cache result page in case Plattner's books are searched
if 'PLATTNER' cp author.
response->server_cache_expire_abs( expires_abs_time = '180000'
browser_dependent = 'X' ).
endif.
|
The result list for querying books by Hasso Plattner is only stored in the cache because you know that these are requested particularly often. The cache entry is invalidated every night at 18.00. This function may be useful for things that must be recalculated every day (such as current prices).