1 Reply Latest reply on Mar 12, 2015 4:14 PM by diego.medrano

    Cachng issue when using API

    Tahir Jadoon

      We had an issue where the viz source had no data. At this point when the users tried to view the viz, it showed nothing. We re-built the data source and after that the first tab showed nothing.

       

      At this point when i went to the second tab, it showed. When i clicked back on tab 1, it showed data as well. In order for tab 1 to show data, we had to click on tab 2 and then came back to it.

       

      This behavior showed for 4/5 users and not all. Here is the api code being utilized on the page. How can i tell tableau to not do aggressive caching? We are not displaying workbook tabs, instead we have custom tabs on the page.

       

      $(document).ready(function () {
                  //SET UP
                  TableauViz.VizUrlProfile = '@Model.VizUrlProfile';
                  TableauViz.VizUrlDelivered = '@Model.VizUrlDelivered';
                  TableauViz.VizUrlPriority = '@Model.VizUrlPriority';
                  TableauViz.CustomerAliasCode = '@Model.CustomerAliasCode';
                  TableauViz.Code = '@Model.Code';
                 
                  //tab click handle
                  $(".tabList > li > a").on("click", function () {
      
                      //get and display the viz
                      TableauViz.getViz($(this));
                      return false;
                  });
      
                  //onload trigger first tab click
                  $(".tabList > li > a[data-sheet='" + TableauViz.tabMenus.Available + "']").click();
              });
              
              
              var TableauViz = {
                  CustomerAliasText: 'AliasCode',
                  CustomerAliasCode: '',
                  CustomerText: 'Customer',
                  CustomerNameText: 'Customer Name',
                  Customer: '',
                  CodeText: 'Code',
                  Code: '',
      
                  viz: '', //global object
                  workbook: '', //global object
                  activeSheet: '', //global object
      
                  VizUrlProfile: '',
                  VizUrlDelivered: '',
                  VizUrlPriority: '',
                  tableauVizContainer: 'tableauVizDiv',
      
                  isResize: false,
                  width: '',
                  height: '',
                  vizUrl: '',
                  vizloadingmessageId: 'vizloadingmessage',
      
                  workbookSheetNames: {
                      Available: 'Available',
                      Delivered: 'Delivered',
                      Population: 'Population'
                  },
                  tabMenus: {
                      Available: 'Available',
                      Delivered: 'Delivered',
                      Population: 'Population'
                  },
                  getViz: function ($tab) {
                      //get the viz
                      var dataSheet = $tab.attr("data-sheet");
                      var isError = false;
      
                      //populate defaults
                      switch (dataSheet) {
                          case TableauViz.tabMenus.Available:
                              TableauViz.height = '800px';
                              TableauViz.width = '940px';
                              TableauViz.isResize = false;
                              TableauViz.vizUrl = TableauViz.VizUrlPriority + "?" + TableauViz.CodeText + "=" + TableauViz.Code + "&" + TableauViz.CustomerAliasText + "=" + TableauViz.CustomerAliasCode;
                              break;
                          case TableauViz.tabMenus.Delivered:
                              TableauViz.height = '700px';
                              TableauViz.width = '890px';
                              TableauViz.isResize = false;
                              TableauViz.vizUrl = TableauViz.VizUrlDelivered + "?" + TableauViz.CodeText + "=" + TableauViz.Code;
                              break;
                          case TableauViz.tabMenus.Population:
                              TableauViz.height = '900px';
                              TableauViz.width = '890px';
                              TableauViz.isResize = false;
                              TableauViz.vizUrl = TableauViz.VizUrlProfile + "?" + TableauViz.CodeText + "=" + TableauViz.Code;
                              break;
                          default:
                              isError = true;
                              $("#" + TableauViz.tableauVizContainer).html('Error!');
                              break;
                      }
      
                      //get ticket and then pull viz
                      if (!isError) {
                          ToolsHelper.getTableauTicket(function (ticket) {
                              TableauViz._populateViz(ticket);
                          });
                      }
                  },
                  _populateViz: function (ticket) {
                      var $vizLoading = $("#" + TableauViz.vizloadingmessageId);
                      var vizDivObject = document.getElementById(TableauViz.tableauVizContainer);
                      var viz, workbook, activeSheet;
                      var options = {
                          width: TableauViz.isResize ? vizDivObject.offsetWidth : TableauViz.width,
                          height: TableauViz.height, //vizDivObject.offsetHeight,
                          hideTabs: true,
                          hideToolbar: true,
                          onFirstInteractive: function () {
                              $vizLoading.hide(); //hide viz loading message
      
                              workbook = viz.getWorkbook();
                              activeSheet = workbook.getActiveSheet();
      
                              //populate global objects to be used later
                              TableauViz.viz = viz;
                              TableauViz.workbook = workbook;
                              TableauViz.activeSheet = activeSheet;
      
                              //resize dashboard
                              if (TableauViz.isResize) {
                                  TableauViz._dashboardResize(activeSheet);
                              }
                          }
                      };
      
                      //dispose
                      if (TableauViz.viz)
                          TableauViz.viz.dispose();
      
                      var vizUrl = TableauViz.vizUrl.replace(/TICKETSWITCH/, ticket);
      
      
                      viz = new tableauSoftware.Viz(vizDivObject, vizUrl, options);
                  },
                  _dashboardResize: function (activeSheet) {
                      if (activeSheet.getSheetType() === 'dashboard') { //worksheet or dashboard
                          //alert(activeSheet.getName());
                          activeSheet.changeSizeAsync({
                              behavior: tableauSoftware.SheetSizeBehavior.AUTOMATIC
                          });
                      }
                  }
              }
      
        • 1. Re: Cachng issue when using API

          Hey Tahir,

           

          It sounds to me like this is an issue with caching and less so with the API. What I would like to know is what your cache is set to (more often, less often, etc.) in the Tableau Server configuration settings. Also, does pressing the refresh button at the top of the viz cause the data to reappear? If you are able to consistently reproduce the issue even after changing your caching settings, I would contact support@tableau.com Feel free to reference this post.

           

          Good luck,

           

          Diego