Hi all,
I've successfully been able to load a ComponentLibrary from an HTTP server, but I would like to be able to cache the response. I notice that every time that I start the channel, it always hard re-downloads the ComponentLibrary (by observing the HTTP server logs).
I tried modifying the node's HTTP agent by using `getHttpAgent().addHeader("Cache-Control", "only-if-cached")` but this doesn't seem to have any effect.
I also tried first downloading into `tmp:/` or `cachefs:/` with `roUrlTransfer` (for which I can successfully add caching HTTP headers), but then when I put a `tmp:/` or `cachefs:/` path into the ComponentLibrary node, the `loadStatus` becomes `failed` (with no additional information).
Any thoughts on how to make this happen?
To me this seems good and proper and normal behaviour.
How would you check for library updates?
Right, so the `Cache-Control: only-if-cached` was just a contrived extreme example to show that this didn't work. In reality, I was hoping to do something closer to "Cache-Control: max-age: 604800, max-stale=3600".
I don't know enough about http cache control really to give you a 100% full answer here but ... if you are only going for 3600 seconds that is 1 hour, surely you would be as well to just let the library be freshly loaded every time and then you don't have to worry about checking for an updated library ... perhaps 'if it ain't broke, don't fix it' might apply here?
I invite you to the Roku developers slack which is a great community, perhaps you can post in the #general channel to see if anyone else has some insights.
https://join.slack.com/t/rokudevelopers/shared_invite/zt-1zkm3krph-DBHjkyrZ3K_g6Mo8s3x~Sg
cheers
just keep in mind any answers in the community slack would be lost in 90 days, due to the nature of Slack Free (and commercial plans being community-unfriendly)
i seem to recollect one can load DCL package from app's pkg:/ - or another DCLs libpkg:/ btw
Ben Combee on the Roku Slack responded with a very helpful answer:
There is no HTTP caching on device for component libraries. There's just no storage space on most Roku devices to hold a cache.
Nas Banov responded as well, with:
DCLs that are in .pkg form are already encrypted and signed with developer ID - and i believe integrity is checked as part of mounting them in the filesystem.Unfortunately, there’s no connection between whose devID was used to sign a DCL, meaning anybody can sign a .pkg and it will load “just fine” in somebody else’s app. To tighten this, an app manifest value declaring signers for DCLs could be added… or! a read-only property for <ComponentLibrary/> which can expose who signed a DCL once loaded - but that would have to be added/documented in future release
Finally, Chris Dwyer-Perkins mentions (in response to loading a component library from pkg:/):
Yea. Maybe. You can include it in your app and do that. But downloading it then loading it from the FS doesn’t work I don’t think.