-
6 Nov 2012 6:46 AM #1
disableCaching in Ext.chart.Chart only works if timestamps happen to be unique
disableCaching in Ext.chart.Chart only works if timestamps happen to be unique
We had a problem with Ext.chart.Chart, where we had 6 charts on the page, and with disableCaching set, it was possible for the cache buster to fail if the timestamp for 2 charts were the same. This would result in a 304 (Not Modified) request for a chart, resulting in a blank white flash applet (no chart rendered). The code in Ext.chart.Chart.initComponent that manages this that contains the bug:
I created a plugin that fixes the problem:Code:if(!this.url){ this.url = Ext.chart.Chart.CHART_URL; } if(this.disableCaching){ this.url = Ext.urlAppend(this.url, String.format('{0}={1}', this.disableCacheParam, new Date().getTime())); }
As this appears to be a global bug, it probably would be better to override Ext.chart.Chart.initComponent instead of use a plugin, but that is the route we chose to take to minimize our regression testing.Code://enforce charts to always have unique caching id by appending this value, instead of using //extjs's algorithm which always just gets the current time in millis, which can fail if the code //runs fast. Ext.ux.plugins.ChartNoCachePlugin = (function() { return { init: function(chart){ if(chart.disableCaching){ chart.url += '_' + Ext.ux.plugins.ChartNoCachePlugin.index++; } } }; }); Ext.ux.plugins.ChartNoCachePlugin.index = 0; //and to use the plugin you would specify in your chart config: plugins: [new Ext.ux.plugins.ChartNoCachePlugin()]
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote