01-24-2013 04:08 PM
Hopefully his is clear enough, let me give some background information.
I have developed a launchpad application to launch the BB Browser and point it to an intranet website for the purpose of allowing end users to access a word document.
The end users need to access this document periodically throughout the day in order to see it's updated content.
The content of this document gets updated on a consistent basis throughout the day, however, a problem arises as the browser caches a copy of this document once it is loaded initially and nothing short of manually clearing the browser's cache via OPTIONS > CLEAR BROWSING DATA > CLEAR NOW will allow the end user to see the updated document. This would need to be done every time the user wants to see the document, which is unacceptable.
I realize using a word document is not an optimal solution but under certain constraints this was the only option available for the moment, which brings me to my question.
Is there any feasible method, be it programatically, via BES settings or programatically to have the browser clear it's cached content automatically?
Barring all those options being ruled out, is there any known method to simulate clicks or controls on a BB, be it internal via the BB API or even 3rd party options where this could be scripted into the app? (think windows GUI automation similar to AutoIt or something along those lines).
Basically, I need a solution where the end user will not be required to go to the options and clear the data themselves, I realize that is the easy answer to this problem, but there are reasons why this is not an option.
I have searched the forums here as well as google extensively and found previously that similar inquiries were not met with positive results, I'm hoping further development or even 3rd party solutions may have arisen to solve this issue.
Any input would be much appreciated.
Solved! Go to Solution.
01-24-2013 04:51 PM
Regarding the first issue, caching is done based on the URL so instead of clearing the cache, all you have to do is add a timestamp to the URL query string and the browser won't load the document from the cache. For example: if your original URL is: http://foo.bar/a.doc, then each time your send a request, send it to: http://foo.bar/a.doc?t=%timestamp% (timestamp is simply the value of System.currentTimeInMillis()).
Regarding the second issue, the BB API enables you to simulate user clicks using the EventInjector:
Hope that helps,
01-24-2013 06:48 PM - edited 01-24-2013 06:48 PM
Have you considered setting an Expires header on the HTTP server for the resource in question to force it to be fetched more often?
There are a variety of ways to do this on the server-side (rather than within the app, which would solve the likely unstated issue of non-BlackBerry users having to redownload too); the techniques are the same as if you had a normal web page which was being too-aggressively-cached by a user's proxy server.
01-25-2013 09:35 AM - edited 01-25-2013 09:36 AM
"Regarding the first issue, caching is done based on the URL so instead of clearing the cache, all you have to do is add a timestamp to the URL query string and the browser won't load the document from the cache. For example: if your original URL is: http://foo.bar/a.doc, then each time your send a request, send it to: http://foo.bar/a.doc?t=%timestamp% (timestamp is simply the value of System.currentTimeInMillis())."
This is ultimately what I ended up doing, passing a variable to the url works perfectly as the BB recognizes it as a new object but it doesn't create more than 1 copy of the file (resulting in who knows how many copies of the word doc being generated).
For posterity, here is a short example of the code I ended up using.
var d = new Date();
var n = d.getTime();
<a href="IntranetURL/TheDocument.docx" onclick="location.href=this.href+'?v='+n;return false;"><img src="button.jpg" alt="The Document" border="0" /></a>