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

Web and WebWorks Development

Reply
New Developer
Posts: 1
Registered: ‎02-06-2009
My Device: Not Specified

Browser cache and "Back" button

I have a BlackBerry Curve (8310), on which I am testing a web-based app in the BlackBerry browser.  My issue has to do with the "Back" button, and caching.  How can I force the page which I go "back" to, to be re-requested from the web server?  Right now, it appears to be using the cached content without any further requests to the server.  I've added all of the recommended anti-caching headers, to no avail.

 

I also need this to work without requiring the user to modify their Browser configurations.

In addition, Javascript may not be an option either.  If I can't find a solution to this, I may have to rely on displaying a disclaimer on said page stating "this page should be refreshed", or something like that.  Not at all ideal.

 

Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Browser cache and "Back" button

Which anti-caching headers did you try?
BlackBerry Development Advisor
Posts: 15,882
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Browser cache and "Back" button

Please see the following link.

 

How To - Control Browser Caching
Article Number: DB-00017

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800878/800733/800790/...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 1
Registered: ‎04-16-2009
My Device: Not Specified

Re: Browser cache and "Back" button

I am seeing the same problem.  The page is cached no matter what.  I am testing by browsing to the page, closing the browser, disconnecting the network, and then opening up the browser and attempting to navigate to the original URL.  The BlackBerry says:

 

"Thenetwork is currently unavailable, however an old version of the page you requested is available in the cache.  Do you want to view the old page?"

 

Why is it asking me this??? The page should NOT be cached!!

 

For reference, here is the RAW HTML (and response headers):

 

 HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Thu, 16 Apr 2009 20:59:55 GMT
Accept-Ranges: bytes
ETag: "50675b4bd6bec91:0"
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Thu, 16 Apr 2009 22:14:20 GMT
Content-Length: 359

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-STORE">
    <title>Expires Example Page</title>
  </head>
  <body>
    THIS SHOULD <B>NOT</B> BE CACHED
  </body>
</html>

New Developer
Posts: 1
Registered: ‎05-15-2009
My Device: Not Specified

Re: Browser cache and "Back" button

The link is almost right. For your meta-tags you will need

 


<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" /> 

 

This has worked for me on the 8310

New Developer
Posts: 3
Registered: ‎05-17-2009
My Device: Not Specified

Re: Browser cache and "Back" button

Hello. I have a similar problem but with the maps application. My custom application has two options to invoke the blackberry maps app. Whenever I back from BB maps and invoke it again, all the previous locations remain on the map.

Thanks in advance.

New Developer
Posts: 7
Registered: ‎05-31-2009
My Device: Not Specified

Re: Browser cache and "Back" button

I've tried the suggestion from the Blackberry knowledge base and also the meta headers suggested above and it still isn't refreshing.  Any further suggestions?

 

I'm testing on the Blackberry 9000 Simulator, 4.6.0.190.

 

Any suggestions would be appreciated.

Highlighted
New Developer
Posts: 7
Registered: ‎05-31-2009
My Device: Not Specified

Re: Browser cache and "Back" button

For a repro, see http://inthebagshoppinglist.com/testback1.htm.  This has a hyper link to a second page.  When you use the back button to go back to the first page, it does not refresh.  There is a popup in the onload event to help illustrate this.  I am seeing this on a 4.6 simulator and a 4.7 simulator.  The test page is trivial and basically consists of the recommended meta tags from the earlier post.  Any suggestions would be appreciated.  Thanks.
New Developer
Posts: 1
Registered: ‎06-01-2009
My Device: Not Specified

Re: Browser cache and "Back" button

Well, I think we are talking about two different problems here. One, how to make the browser to refresh the previous page when you press the Back buttom. As far as I know, this is not possible since the browser doesn't do any kind of roundtrip to the webserver when you prest the back button, no matter if it is a BB browser or a normal desktop browser.

 

The other problem is how to avoid that the browser shows you the cached version of a page, instead of doing a roundtrip to the web server to pick an updated version of that page.  I tested all solutions mentioned in the post above and non of them seems to work, at least for my 8320 emulator.

 

But I found another approach here:

http://na.blackberry.com/eng/devjournals/resources/journals/aug_2008/singlesignon.jsp

 

 Just trying that right now to see if it works

 

 

New Developer
Posts: 7
Registered: ‎05-31-2009
My Device: Not Specified

Re: Browser cache and "Back" button

To be clear, my test page DOES correctly refresh when you press the back button in both IE and Firefox.

 

The first three posts suggested that proper caching headers are a valid solution to the back button problem, because if the page isn't cached then the browser will go request a new version of it.  That seems to be exactly what happens with my test page in IE and Firefox, and apparently gejimayu18 had it working on an 8310.