Caching Elements in Plone

     

You can be proactive in your Plone site administration by monitoring and caching several different elements that make up the site. For example, you can control the number of objects cached in the Zope Object Database, and you can cache the content of pages and slots ”items that usually contain dynamic content. The next few sections provide some basic insight into how to cache Plone elements so that your users experience even faster response times than usual.

ZODB Caching

Earlier in this chapter, you used the Zope Management Interface to access the Database Management control panel. You can use this area to monitor the elements within the ZODB and modify any cache settings, as needed. Click on the Activity tab to display a real-time graph of the number of objects stored and loaded in the ZODB. An example is shown in Figure 8.6.

Figure 8.6. Zope Object Database activity snapshot.
graphics/08fig06.gif

The statistics in this chart will help you to determine whether changes are needed in your cache parameters. According to Plone developers, you should be concerned if you see 800 “1,200 object loads continually over the activity period, and you should then think about modifying your cache parameters to reduce these numbers . Your mileage might vary, of course, because a machine with large amounts of RAM and processing speed can handle more transactions than a server with the minimum recommended configuration.

Cache parameters are managed under the aptly named Cache Parameters tab. Under this tab, you will see a list of current statistics:

  • Total Number of Objects in the Database ” This includes objects stored in memory and on the file system.

  • Total Number of Objects in Memory from All Caches ” This helps you determine the amount of memory currently used by Zope.

  • Target Number of Objects in Memory Per Cache ” This isn't a ceiling; it's a target. When processing a request, the ZODB allows the number of objects to surpass this number, if required, but it immediately reduces the number of objects to the target or below when the request is complete.

  • Total Number of Objects in Each Cache ” This is a heading for a table that displays each current object cache, the number of objects in the memory of that cache, and the number of ghost objects in that cache.

Note

A ghost object is a very small object that you don't need to worry about because it has a very small footprint.


Next, you'll learn a bit about the HTTP Accelerated Cache Manager and the RAM Cache Manager, both of which are installed in the Root folder of your Zope instance during the Plone 2.0 setup.

Additional Cache Managers

When Plone is installed, two cache managers are installed along with it, in the Root folder of your Zope instance.

Tip

If you do not see these managers already installed, you can add both via the drop-down menu in the ZMI workspace frame.


These are the default Zope cache managers:

  • HTTP Accelerated Cache Manager ” Adds cache- related headers to objects

  • RAM Cache Manager ” Caches objects in RAM to hasten their retrieval

The HTTP Accelerated Cache Manager

The HTTP Accelerated Cache Manager enables the administrator to modify the cache headers of outbound activity. For example, unless you plan to constantly change the icons used to represent different content types ”files, URLs, images, and so forth ”you can attach headers to these items so that they will stay cached for a very long time. Similarly, if you have some documents that change but not all that often, you can cache them for a day or even a week. By setting these cache-related headers, you reduce the number of incoming requests to the web server and, in turn , the request of objects from the Zope server.

To use the HTTP Accelerated Cache Manager, follow the HTTP Accelerated Cache Manager link in the Plone instance of the Zope Management Interface. To set the overall HTTP Accelerated Cache Manager settings, go to the Properties tab for this object. You will see the following form fields:

  • Title ” Optional. This is the name of your instance.

  • Interval (Seconds) ” This is the number of seconds for the object to be cached. It defaults to 3600 seconds (1 hour ).

  • Cache Anonymous Connections Only ” If this is checked, it caches only requests made anonymously, or by users who are not logged in.

  • Notify URLs (via PURGE) ” You can specify the URLs of caches that should receive PURGE directives, thus clearing their caches at the appropriate times.

The RAM Cache Manager

Unlike the HTTP Accelerated Cache Manager, the RAM Cache Manager performs no tasks related to network traffic. Instead, the RAM Cache Manager stores the results of DTML methods , Python scripts, and SQL queries in memory, for faster retrieval when repeatedly requested .

To use the RAM Cache Manager, follow the RAM Accelerated Cache Manager link in the Root folder of the Zope Management Interface. To set the overall RAM Accelerated Cache Manager settings, go to the Properties tab for this object. You will see the following form fields:

  • Title ” Optional. This is the name of your instance.

  • REQUEST Variables ” These are used as the cache key(s).

  • Threshold Entries ” This defaults to 1000 and represents the maximum number of entries stored in the cache. If the cache is taking up too much memory, reduce this number.

  • Maximum Age of a Cache Entry (Seconds) ” This defaults to 3600 seconds (1 hour).

  • Cleanup Interval (Seconds) ” This defaults to 300 seconds. Reduce this number if the RAM cache causes too much fluctuation in memory usage.

Caching Items in Plone

When you have decided to cache an object, you must decide which cache manager to use. If you are caching a document, an image, or another similar content type, the HTTP Accelerated Cache Manager is for you. Through the Zope Management Interface, navigate to the object that you want to cache and select it. The object should have a Cache tab. Under this tab, use the drop-down menu to select the appropriate response to Cache This Object Using and press the Save Changes button. The item then is cached.

To see a list of items that are regularly requested but are not cached, follow the HTTP Accelerated Cache Manager link in the PloneInstance folder in the ZMI, and then select the Statistic tab. You will see a list of documents, such as / PloneInstance /zope_icon.gif , a static image file. Click on the linked name of this item, select the cache manager to use, and press the Save Changes button. The object then is cached.



Plone Content Management Essentials
Plone Content Management Essentials
ISBN: 0672326876
EAN: 2147483647
Year: 2003
Pages: 107
Authors: Julie Meloni

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net