Swiff Chart Generator has a built-in caching support.
When caching is enabled, Swiff Chart Generator stores the data, the layout parameters as well as the corresponding generated chart data in a cache directory on the hard disk.
Each time a client requests the same chart (same data series, same chart style and parameters), the server simply sends back the previously generated Flash movie or image without having to re-generate it, thus considerably improving the performance. Once a chart is stored in the cache, the server does not consume CPU for movie or image regeneration.
The cache is automatically managed by Swiff Chart Generator so that it never allocates more than the maximum amount of disk memory specified by the configuration.
If tha data being graphed is often the same, using the cache is recommended. Enabling the cache is such cases will highly improve the performance. On the contrary, if the data being graphed is never, or rarely the same, using the cache is not recommended.
In Swiff Chart Generator, the caching has 3 different parameters:
There are 2 methods to activate the caching in Swiff Chart Generator on Windows:
There are 2 methods to activate the caching in Swiff Chart Generator on UNIX systems:
The list below enumerates all the methods provided to manage the cache in your source code:
Method | Definition |
---|---|
UseCache | Enables or disables the caching system. |
SetMaxCacheSize | If caching is enabled, specifies the maximum size of the cache in KB. |
SetCacheName | If caching is enabled, specifies the name of the public cache relative to the web server root. |
SetPrivateCacheDir | If caching is enabled, specifies the path of the private cache directory. This path is absolute, it is not relative to the web server. (optional) |
ClearCache | If caching is enabled, this method forces the cache to be cleared. |
Note: if you call a method which does not require the cache and if, in the same time, you want Swiff Chart Generator to use the cache for better performances, you must call the method UseCache to enable the cache or select Force cache in the Control Panel.
Method | Always Uses cache |
---|---|
GetHTMLTag | X |
GetOutputLocation | X |
ExportAsResponse | |
ExportAsFile | |
ExportAsBinary |
The VBScript code below illustrates the use of the cache when calling the ExportAsResponse method:
<% @Language=VBScript %> <% Dim chart Set chart= Server.CreateObject("SwiffChartObject.ChartObj") chart.SetTitle "Movie Revenues" chart.SetCategoriesFromString "January;February;March" chart.SetSeriesValuesFromString 0, "187;110;159" chart.LoadStyle "pie\Geneva2" chart.SetCacheName "/charts_cache" chart.UseCache True chart.ExportAsResponse Set chart= Nothing Response.End %>
However, since the method GetHTMLTag automatically uses the cache, the code below does not require the UseCache method to be called.
<% @Language=VBScript %> <% Dim chart Set chart= Server.CreateObject("SwiffChartObject.ChartObj") chart.SetTitle "Movie Revenues" chart.SetCategoriesFromString "January;February;March" chart.SetSeriesValuesFromString 0, "187;110;159" chart.LoadStyle "pie\Geneva2" Response.Write chart.GetHTMLTag Set chart= Nothing %>
The Swiff Chart Generator Control Panel enables you to fully configure the caching system. You can set all the required pathnames, the cache size as well as enable the cache for all the chart requests.
Read the Swiff Chart Control Panel page for a complete description of the dialog.