Your Digital Media Has Never Looked So Good

 
User avatar
Oak-Beard
Topic Author
Posts: 17
Joined: Wed Apr 22, 2015 5:13 am

caching behavior of roUrlTransfer

Wed Aug 19, 2015 6:31 am

I have a private channel that accesses some JSON files with configuration data. Nothing fancy, just a basic roUrlTransfer:
    req = createObject("roUrlTransfer")
    req.setCertificatesFile("common:/certs/ca-bundle.crt")
    req.setUrl(targetUrl)
    response = req.getToString()
    config = ParseJSON(response)

This works fine. The only problem I have is that when I change the data files on my server, the new data doesn't appear in the roUrlTransfer response until the next day. The problem is definitely not my web server since pulls of the data file via my desktop browser are returning the correct (i.e., latest) results. I have tried several approaches to trying to get the data changes to take affect immediately (i.e., using system settings to check for updates, restarting my Roku, publishing an updated package, all of the above).

My suspicion is that the design assumption on the part of the Roku team is that data like this would/should be included within the package itself, thus the package update mechanism would keep everything in-sync and up to date. I don't have that option however for a variety of reasons (i.e., my customer's business model). So the bottom line is, is there a way to force any changes in data files to take effect on-demand rather than on what appears to be a 24 hour cycle?

Thanks
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: caching behavior of roUrlTransfer

Wed Aug 19, 2015 7:21 am

Are you hosting your JSON files on a CDN? I am and any change I make can take up to 8 hours to propagate depending on my cache-control settings for that file. The CDN wont request a new core copy until the cache setting is expired. Doesn't sound like it since your browser is pulling correctly, but asking in case your browser looks to the core storage url and your Roku app to the CDN url.
FlixRaider channel
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: caching behavior of roUrlTransfer

Wed Aug 19, 2015 10:51 am

Oak-Beard wrote:
... is there a way to force any changes in data files to take effect on-demand rather than on what appears to be a 24 hour cycle?

Try adding random querystring at the end to suppress caching, e.g.
 req.setUrl(fileURL + "?rand=" + rnd(2000000000).toStr())

People often use this shotgun approach instead of tweaking Cache-Control / Last-Modified.
 
User avatar
Oak-Beard
Topic Author
Posts: 17
Joined: Wed Apr 22, 2015 5:13 am

Re: caching behavior of roUrlTransfer

Fri Aug 21, 2015 8:28 am

Thanks for feedback. I'm going to try EnTerr's approach. It's a kludge but it should suffice for speeding up development testing.
 
floatleftinteractive
Posts: 33
Joined: Mon Feb 08, 2010 2:58 pm
Location: Florida | NYC
Contact:

Re: caching behavior of roUrlTransfer

Fri Aug 21, 2015 10:00 pm

you can try using enableFreshConnection() on your roUrlTransfer object, http://sdkdocs.roku.com/display/sdkdoc/ ... nasBoolean, which will use a fresh connection each time instead of pulling from curl's cache.
--
Float Left Interactive Team
www.floatleftinteractive.com
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: caching behavior of roUrlTransfer

Sat Aug 22, 2015 10:49 am

floatleftinteractive wrote:
you can try using enableFreshConnection() on your roUrlTransfer object, http://sdkdocs.roku.com/display/sdkdoc/ ... nasBoolean, which will use a fresh connection each time instead of pulling from curl's cache.

I don't think this is related. CURLOPT_FRESH_CONNECT makes sure that an HTTP connection won't get cached for re-use - we are talking about the keep-alive of HTTP 1.1, which makes much faster the download of multiple content from the same server by avoiding connection tear-down and build-up delays. So this is a way to void that goodness for whatever reason. It's about caching connections, not content.
 
sonnykr
Posts: 70
Joined: Thu Jun 12, 2014 11:57 am

Re: caching behavior of roUrlTransfer

Wed Oct 21, 2015 12:08 pm

I am having the same issue. I've added my comments here: viewtopic.php?p=340620

The response I get from brightscript code is different (expired) from what I get from a curl/chrome client. I added a cache buster (a random value) at the end of the url, and it worked just fine.

http://www.example.com/programs/channel ... 2015-10-21
retuned expired data and fixed by adding a random value

http://www.example.com/programs/channel ... 21&random=<some_random_value>

This works fine for query params method, but I have REST apis that does not allow that extra value. Is there a way to overcome this? I added Cache-Control : cache-none header, doesnt seem to be working either.

Any help appreciated. Thanks!

Who is online

Users browsing this forum: No registered users and 8 guests