Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
GSPSDev
Posts: 2
Registered: ‎01-24-2013
My Device: Bold 9700
My Carrier: Bell
Accepted Solution

Word document and clearing Blackberry browser cache automatically

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.

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Word document and clearing Blackberry browser cache automatically

Hi @GSPSDev,

 

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:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/EventInjector.html

 

Hope that helps,

 

E.

Please use plain text.
Developer
lewellyn
Posts: 110
Registered: ‎10-22-2011
My Device: PlayBook, Bold 9650, Dev Alpha A
My Carrier: Sprint

Re: Word document and clearing Blackberry browser cache automatically

[ Edited ]

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.



Is there a helpful or useful post in this thread? Click the thumbs up on it so that other people can find it more easily!
Like this post too! :smileyvery-happy:
Please use plain text.
New Contributor
GSPSDev
Posts: 2
Registered: ‎01-24-2013
My Device: Bold 9700
My Carrier: Bell

Re: Word document and clearing Blackberry browser cache automatically

[ Edited ]

 

"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).

Thanks!


For posterity, here is a short example of the code I ended up using.

<script type="text/javascript">
var d = new Date();
var n = d.getTime();
</script>

<a href="IntranetURL/TheDocument.docx" onclick="location.href=this.href+'?v='+n;return false;"><img src="button.jpg" alt="The Document" border="0" /></a>

Please use plain text.