In terms of performance, dynamic pages require the most resources. Next, static pages served from the system’s disk offer notably fewer demands on system resources. initially, pages served from the system’s RAM offer the best performance and least demand on system resources. This is where the cache size comes into play. The cache size indicates how much RAM to make available to retain copies of the most recently processed templates. As new templates are processed and the cache is full, older templates are removed to make way for the new. At first, it might seem that this offers a quick and easy solution to performance problems: Set the each size high enough so that all your templates can fit in the cache. If you have enough system RAM, this will definitely have a marked effect on performance. However, the formula is not so simple. You need to take the amount of available physical RAM and other software running on your system into consideration. Remember, all running applications and services require RAM. When physical RAM is used up, the system reverts to using virtual memory, treating hard-disk space as additional RAM.
This allows for more applications to load than physical memory renders possible but, as more and more virtual memory is used more and more often, the performance of the system can grind to a halt because it is constantly accessing the hard drive for information
that should be in physical RAM.You need to keep this problem with virtual memory in mind when setting your cache size. You may have enough RAM at first glance to create a cache for storing all your templates. But you may not have enough to do this and still allocate enough physical RAM to other processes that require it, and the end result will be drastically decreased performance. On Windows Nf systems you can get a sense of your system’s current usage of
physical and virtual memory from the Task Manager. If your system consistently has large amounts of physical RAM free, then you can probably use a good portion of it for , your Cold Fusion each”. However, if your system is regularly using large amounts of virtual
memory, the best path to improved performance may be to add more physical memory to your server.
Limiting Dynamic Requests with CF CACHE
With a Web application environment such as ColdFusion, the dynamic nature of most pages is the source of many performance problems that arise. However, in many cases pages are built out of queries against data sources that do not change frequently. For instance, consider a site that displays an online catalog based on a products database that is updated weekly. Every time a us~r views a page in the catalog, a unique query is made of the products database even though the results of the query (and the resulting HTML that is generated by the template) will be identical to the results generated by the request from the preceding user to access the page. The CF CACHE tag provides a way to cache dynamically generated pages in static files that can be returned to the user instead of the dynamic pages. In our example, this would mean that the first person to access a Cage being cached would receive the dynamically generated content, but subsequent users would receive the cached static page, greatly reducing demands on the server’s resources. This is all oversimplified, of course. For instance, you need to ensure that the cached document is regenerated at frequent enough intervals to ensure that it reflects the most recent updates to the data sources it accesses. Fortunately, the CF CACHE tag makes this easy to achieve.
CF CACHE maintains a mapping file called cf cache. map.which is used to associate requested templates with static cache files. The file is stored in the same directory as the cached files it relates to and contains entries similar to a Windows file To use the Cachet, you simply need to include it in the templates you wish to cache as static pages. The tag takes the following attributes: