Reloading the home page on TVML app

I have a TVML app with a menu bar and 4 sections. The home page (first in the menu bar) is built from a remote TVML with remote JSON file for data. Once the JSON file and TVML files are loaded I use Mustache to render the template. Every time the user navigates to a different page and then uses the menu to return to the home page, we want the latest TVML and JSON to be loaded and displayed. However this never happens. The home page remains the same no matter what changes I make to either remote file. From my debugging I see that the remote files are actually loaded and rendered, so I do manage to get the latest template and data. However, when it comes to displaying this on the screen, the following doesn't refresh the page:


presentMenuBarItem(doc, menuItem) {
        var feature = menuItem.parentNode.getFeature("MenuBarDocument");
       if (feature) {
            var currentDoc = feature.getDocument(menuItem);
          
            if (!currentDoc) {
                feature.setDocument(doc, menuItem);
            }
        }
    }


I have verified through debugging that the doc passed into this function is the updated version. However the old one is shown every time.


If I reload the app I get the new version but only in the simulator. In the actual Apple TV, even if I restart I still get old data.


I also tried making it work upon resume by clearing the stack and reloading the menu and home screen, but again, even though it works on the simulator, it doesn't on the apple TV, the data remains the same, as well as the template and old images.


App.onResume = function(options) {
    navigationDocument.clear();
    pushLoadingDoc();
    resourceLoader.getNavigation();
}


How can I make that function render the updated screen? Our home page tvml and json files are constantly being updated and we need the latest displayed to our users.


Thank you.

Replies

Hello,


By default, The TVML engine stores TVML files and Javascript files in the Application cache.


For TVML, you can solve this by downloading the xml files via XMLHttpRequest and specify a no-cache header in the request ("Cache-Control": "no-cache").


For Javascript, this is not that simple.

You can only workaround the App-cache system by adding a fake parameter that change everytime (ex: http://mydomain/Application.js?timestamp=<timestamp-value>).

This works fine but it cancels also the HTTP server cache mechanisms and this can generate overloading.


FredG