Discussion Forums  >  Suggestions, Ideas, Wish List

Replies: 24    Views: 120

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
06/22/12 10:55 AM (13 years ago)

Online/Offline content and how to trigger a refresh for external pages

I am building an app with all the html content and images app outside the buzztouch control panel. I'm using pages of Screen Type : HTML Doc which links to html files on a separate server. The problem is the device caches the document for offline use, but the app does not automatically refresh when any of those docs change. If I use a page of type Custom HTML / Text in the control panel, I don't have that problem, the app detects the content has changed even when the page is set to be cached when offline - that is the behaviour I'm looking for, but for external content. My thinking is that it would be inefficient and slow for an app to check the content of all external pages for changes, but maybe we could have a single page, of new page type that the app would look for whenever it starts and if that single page changes, the app would do a ‘This apps content has changed would you like to refresh?’ action. Or perhaps if a device has been offline or out of internet coverage, a buzztouch app could do an 'auto refresh'? Or there might be a better way? Thoughts anyone?
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 11:02 AM (13 years ago)
The default behavior for the Custom HTML/Text screen is to refresh each time the document is retrieved, even if you set it to cache only in the Advanced Properties. It will refresh this page each time it gets loaded, as you've noticed. I'm assuming you're saying that when you load the HTML Doc screen, the page does not automatically refresh? Versus and automatic refresh of the entire app when the pages change, without actually loading the page itself? If an HTML Doc page linked to an external URL changes, it should get changed when the user loads that page in the app, and it should cache that page for future use. If that's not happening, that's a bug I think. I believe I understand that you're looking for an automatic refresh of ALL external content, whether the user taps on that content or not, and I'm not sure how to address that! Mark
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/22/12 11:34 AM (13 years ago)
Hi Mark, thanks for the interest What I'd like is to have an app that doesn't need the internet to be on all the time to view pages, but will update as the internet is available and when external content changes. If I author the content and keep it in the control panel environment, this meets my caching & detection needs, but for this app, I need the content to be external. If I use a cached page (of type HTML Doc), when tapped and the device is online, it shows what is in the cache, but not what is live. If I use the a refresh button manually, that brings in the live content. If I use pages based on screen type Custom URL, they never cache. If I use pages based on screen Type : Custom HTML / Text, they work just the way I want, but the content lives in the control panel only. In a nutshell, the problem is when that external cached content changes, my app doesn't automatically notice.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/22/12 11:35 AM (13 years ago)
I forgot to mention I am self hosted, using IOS.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 11:37 AM (13 years ago)
Gotcha...that's what I thought you were asking...automatic refresh of all changed content that's not changed through the control panel (which would automatically initiate a refresh). Not sure how to tackle that! Perhaps somebody on the forum will weigh in...very interesting topic. Mark
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/22/12 11:56 AM (13 years ago)
The solution is to make your html a manifest file. Fred
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 11:57 AM (13 years ago)
What exactly does that mean, Fred, and how would you implement it? Can you provide some step-by-step? Mark
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/22/12 12:02 PM (13 years ago)
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 12:06 PM (13 years ago)
Yep, I discovered that while I was waiting for you to respond. I don't think that would work in this situation. As I read that tutorial, it basically specifies a set of resources that should be downloaded and cached when the browser is opened to that page. That last part is key. The browser has to the on the page that has the manifest settings in it, otherwise there is no way for it to work (as far as I can understand). What AlanMac wants to do is this: * Make changes to his HTML files that are located at a URL * Have the app automagically update ALL the files that are changed, regardless of whether the user has viewed them or not, and without having to open them up individually in the app and cache them I don't think the manifest idea can handle this. What's needed is a way for the app to automagically retrieve all the files that it knows about on a regular basis, so it always has the latest content. Mark
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
06/22/12 12:15 PM (13 years ago)
"when that external cached content changes, my app doesn't automatically notice." This is the purpose of the reportToCloudURL: The app checks that URl for the "last modified time" and updates as needed. In fact, copy the reportToCloudURL you're using (be sure it includes the necessary app id and other keys) and paste it in your address bar. You'll see what it's providing. Individual screens do not check for content updates, the app does. Another way to say it, "if any content has changed, refresh everything." If the "last modified" value on the device is different than the last modified value provided by the reportToCloudURL, the user will be prompted to refresh. This idea completely ignores the idea that an HTML may or may not have been altered. HTML a manifest file: Although using the cacheing mechanism's available in HTML5 is possible, I don't think @AlanMac is asking about that idea. He's asking how his BT app works, and how it handles HTML / Documents / Content.
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/22/12 12:16 PM (13 years ago)
The webkit is a browser built in, should work. Fred
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 12:17 PM (13 years ago)
OK, if the webkit is the solution, how do you implement an automatic firing of it to grab the data specified by the manifest? And since the manifest is associated with specific HTML files, how would you cause it to launch for all files in the app? Mark
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/22/12 12:33 PM (13 years ago)
@David, I understand Individual screens do not check for content updates, the app does. Another way to say it, "if any content has changed, refresh everything." If the "last modified" value on the device is different than the last modified value provided by the reportToCloudURL, the user will be prompted to refresh. This idea completely ignores the idea that an HTML may or may not have been altered. I take this to means that if an eternal html content changes, the nothing would happen, but if something internal changed everything would update. Correct? Mark, how do you implement an automatic firing of it to grab the data specified by the manifest? My understanding is by opening the screen. And since the manifest is associated with specific HTML files, how would you cause it to launch for all files in the app? It won't, it's file specific. Just a tool, but a tool. Fred
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
06/22/12 12:34 PM (13 years ago)
Let's not get off track here. @Fred, the question isn't about how to use HTML5 to handle cache. The question is about "Online/Offline content and how to trigger a refresh for external pages." Thats all, nothing more nothing less. It's about trying to answer the actual question, not raise more question. Introducing new technologies and ideas is fine, and sometimes a great approach. Heck, sometimes it turns out the be a better approach! But, generally we are all better off if we get the first question answered before experimenting with new ideas. Something like this sounds entirely different than "the solution is to make your html a manifest file. " "There are all sorts of ways to handle online and offline content in your app, especially when dealing with HTML and other web-type documents. You may even consider looking into using the browsers native caching features. Your buzztouch app does it this way....... "
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 12:35 PM (13 years ago)
"My understanding is by opening the screen. " Exactly why this won't work. The screen has to be open. AlanMac wants to avoid that...just grab all the updated content so it's ready for WHEN the user happens to tap on the screen. The manifest is a great solution indeed for some things, just not here. Mark
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
06/22/12 12:39 PM (13 years ago)
I missed this part: "AlanMac wants to avoid that...just grab all the updated content so it's ready for WHEN the user happens to tap on the screen" The built in methods won't account for this. They WILL remove all the cached content, to force a refresh when the screen is "tapped" (this is called lazy loading sometimes) but it will not download "all the content so it's ready when the user happens to tap on a screen." Big difference that I felt it was important to clarify.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/22/12 12:47 PM (13 years ago)
I appreciate the response guys, thanks. David, I think you are saying that the app checks the timestamp of an object in the cloud, does a comparison and decides to do a refresh based on that. That explains if external pages don't/can't change that, then the app doesn't know a cached page has been updated. Mark is right about what I'm trying to do, but erhaps it doesn't *have* to be whole app refresh. If a when I tapped to an individual page that was cached, perhaps it would be OK if the app tried to retrieve the live version and displayed the cached verson if it can't get the live page, although I don't know if that is inefficient.
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/22/12 04:49 PM (13 years ago)
Perhaps a simple HTML redirect would solve your problem. Embed the HTML Doc in the app. Have the HTML redirect to the latest version online. Not as sophisticated as a HTML manifest file, but should provide what you seek (but with it's own limitations). Fred
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/22/12 04:57 PM (13 years ago)
Currently buzztouch will grab the latest copy of an HTML file at a URL and cache it when the user taps on that screen, so it's already in place. It can't get cached, though, until a user taps on it for the first time. So, if they are offline for that first time, the resource will be unavailable. The manifest idea seems good, but I think it might only be useful for parts of the page (like common images), and not the whole doc itself. Embedding the HTML doc in the app, with a redirect isn't a half-bad idea. It would cause a force refresh if the user taps on the menu item for that page, and if no network exists, it would still have a page to view. Certainly a possible solution (though doesn't pass your "efficient" tes!)! Mark
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/22/12 05:07 PM (13 years ago)
The manifest idea seems good, but I think it might only be useful for parts of the page (like common images) That's actually a good understanding what the manifest does, but when you throw in multi-page html doc combined with dynamically created pages, then you realize how it's much more that just about a few images. It'll download pages that the users don't frequently visit, so they'll be there when the user needs them. Sorta becomes an app within the app. IMHO exactly what the original post is about. Fred
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/23/12 03:13 PM (13 years ago)
I just had a look at the contents of the cloud URL for my app - it was :- {"lastModifiedUTC":"Sat, 23 Jun 2012 14:47:35 -0700"} So, if I was able to update the contents of this from outside the BT control panel, would my app think it needed to refresh?
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/23/12 03:26 PM (13 years ago)
Just took a look at the Config file and I don't see a time stamp there. As I understand the reportToCloud URL provides the time stamp. Where you would modify it I'm not sure. Fred
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
06/23/12 03:34 PM (13 years ago)
http://www.buzztouch.com/docs/v1.5/reportToCloud.php My thinking is that it would be inefficient and slow for an app to check the content of all external pages for changes, but maybe we could have a single page, of new page type that the app would look for whenever it starts and if that single page changes, the app would do a ‘This apps content has changed would you like to refresh?’ action. Modifying the time stamp could be "inefficient and slow". It would get the user updated info, but it has the cost of always updating. Fred
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
06/23/12 04:08 PM (13 years ago)
Hi Alan, I see your line of thinking here! Unfortunately, what's happening is that it's looking for changes to the configuration data (BT_Config.txt, in essence) for the app. For instance, if you add a new screen, change some property on another...anything that would cause a change in the config file, then it would trigger an update the next time the app checks in. This would not help the issue with your off-app HTML files. Since the config file contains only a reference to the location of the file, it doesn't know anything about the contents of the file. And that means the content can change, and the app has no knowledge of it, nor does it care! So, unfortunately no solution yet to causing the app to update ALL the files you want, even if a user has not tapped on the menu item for that file. Mark
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/24/12 03:16 AM (13 years ago)
Thanks Fred, David & Mark for your help and ideas so far. I decided to do a little test to confirm my understanding, which is better than it was. I created an app with two pages (amongst others), called page1 and dummypage. page1 caches an external html file and is used in a menu., dummypage is a local page in the control panel but not in a menu. I ran the app, tapped on the menu item for page1 - page1 showed. I closed the app, updated the remote content for page1 and opened the app again. I tapped to navigate to page1 - it showed the old cached content (as expected). Then I closed the app. I went into the control panel, went to dummypage and saved it without making changes. Then I opened the app. The first thing I saw was the 'content has changed' alert (presumably because the time in the report to cloud url had changed). I tapped yes, then navigated to page1, which showed the updated content for page1. My iPhone was online throughout. My conclusion is that the app will refresh all its data and links if the time stamp in the Cloud URL file changes. Do you agree? This overall refresh effect solves my problem, but I have no idea how to update the cloud URL contents without being at the control panel.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.