
Oak-Beard
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2015
06:31 AM
caching behavior of roUrlTransfer
I have a private channel that accesses some JSON files with configuration data. Nothing fancy, just a basic roUrlTransfer:
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
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
6 REPLIES 6
sjb64
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2015
07:21 AM
Re: caching behavior of roUrlTransfer
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.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2015
10:51 AM
Re: caching behavior of roUrlTransfer
"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.

Oak-Beard
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2015
08:28 AM
Re: caching behavior of roUrlTransfer
Thanks for feedback. I'm going to try EnTerr's approach. It's a kludge but it should suffice for speeding up development testing.
floatleftintera
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2015
10:00 PM
Re: caching behavior of roUrlTransfer
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
Float Left Interactive Team
www.floatleftinteractive.com
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2015
10:49 AM
Re: caching behavior of roUrlTransfer
"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
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2015
12:08 PM
Re: caching behavior of roUrlTransfer
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!
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!