Caching

The Plotalot Plugin can cache your charts on your server, reducing the amount of work needed to re-produce the chart for the next user who requests it. For charts that use complex queries or charts that don't change very quickly, this is a worthwhile optimisation.

When it produces a chart, Plotalot first has to execute the database query(ies), then analyse the data and produce the Javascript that will draw the chart. The Javascript becomes part of the web page delivered to the browser, and the browser executes the Javascript to render the chart. When the Plotalot Plugin caches a chart, it stores the Javascript in a file on the web server. If the same chart is requested within the allowed cache time, Plotalot retrieves the text file instead of accessing the database and creating the chart from scratch.

The "Use Cache If Error" option determines if the plugin can use an old, expired, cached version of the chart if a new chart cannot be drawn. For example, if the data feed to your database fails, it might be better to show the most recent chart rather than an error image or error message. If set to "Yes", this option takes precedence over the "error_img" and "error_txt" parameters.

You can specify the "Cache Time" and "Use Cache If Error" options globally for all charts in the Plugin Manager, or on the plugin call. Parameters passed on the plugin call take precedence. To enable caching for all charts, set the "Cache Time" in the Plugin Manager to a non-zero number. This is the number of seconds the cached version is valid.

Here's how to specify the options on the plugin call:

{plotalot id="42" cache_time="60" use_cache_if_error="yes"}