Caching On BlackBerry Browsers


Hello Mobile Web Developers,

As we all know BB mobile devices are one of the most popular and widely used by Mobile Users all over the world. So, this is obvious for any mobile web developer to build the Application to run on BB browsers. While testing on BB devices or emulators you’ll see mostly rendering issues. But I am not going to explain about those issues. Here I’ll share something “Good to Know” concept very specific to BB browsers caching.

BlackBerry browser has built in caching mechanism. In general caching mechanism is used to increase the UI experience and reduce reloading the content again and again. So, for this reason BB has done a good thing by introducing this default caching.

But think about the dynamic content on your application and needs to load based upon user selections or inputs. In these cases the caching will cause issue by not refreshing on page refresh. No matter what, the page will get the old data on each refresh. This is not GOOD!!!!! Right…

So, what’s the solution to this????

We need to tell the browser that the particular page in not asking for caching…Means we need to modify the particular page request header with no-caching elements.

This can be done by adding the <META> tag or through code-behind also.

**************************************************************************************************

<meta http-equiv=”CACHE-CONTROL” content=”NO-CACHE” />

<meta http-equiv=”EXPIRES” content=”0″ />

**************************************************************************************************

 

But this could not be the solution for all BB models. So its better to include the below lines of code into your MasterPage or BasePage, if you want it for entire site. Else do it for particular pages.

 

**************************************************************************************************

HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(false);

 HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);    

HttpContext.Current.Response.Cache.SetNoStore();   

Response.Cache.SetExpires(DateTime.Now.AddSeconds(0));

**************************************************************************************************

 

Cheers!!!!!

Swagat

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s