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

Posts: 40
Registered: ‎05-12-2012
My Device: 9800
My Carrier: Virgin mobile

Issues with Caching



OK so here is the makeup of my system. I am writing a web app for the blackberry. It is using Webworks API, Knockoutjs.Jquery, Ajax

The software contains a list of messages. Each message has an avatar, a like and a reply icon. The avatar has an option to be switched off and a default avatar used.

All these images are stored locally i.e. art/image.png

Once logged in there is a single HTML file. This is broken down into a number of div's that are the relevant pages of the app and are switched using show and hide and also turned on and off using the knockoutjs IF statement which does not even render then unless a true confition is set. All are false unless they are the current page.

The data for these pages is read from a database and displayed using a knockoutjs observable array. The markup for that page is generated using knockout's for each. so dependant on the number of messages you get chunks of HTML created. each of the chunks contains reference to these images as so:-



										<div class="like_holder" style="display:inline" ontouchstart="touchStart()" ontouchend="touchEnd(event,this)" data-bind = "click: likeIt.bind($data, thread(),'thr'), attr: { 'id': 'th_lh' + $index()}">
											<img src="art/like_icon.png" class="like_icon" x-blackberry-focusable="false" />
											<a class = "mi_likes" x-blackberry-focusable="false" ><span class = "likes" data-bind = "text: likes"></span></a>
										<div class="reply_holder" style="display:inline" ontouchstart="touchStart()" ontouchend="touchEnd(event,this)" data-bind = "click: sendReply.bind($data, thread(),user(),'th_mb' + $index()), attr: { 'id': 'th_rh' + $index()}">	
											<img src="art/reply_icon.png" class="image_icon" x-blackberry-focusable="false" />	
											<a class = "mi_replies" x-blackberry-focusable="false" ><span class = "replies" data-bind = "text: replies"></span></a>

 As you can see from this the filename for each like or reply icon will always be the same.

Now down to what is happening

As I continue to use the software the memory consumption by these images is constantly growing like it is allocating each occurrance of the like or reply icon (and avatar - which I have set all to default so they are the same) seperately.

Should it not be using the cache? Does the cache work this way? I would have though the first time it was loaded it would have been placed in a cache and when rendering the HTML it would just access 1 image in the cache. Am I a complete numpty? Could anybody explain where my reasoning is wrong.


My config.xml contains


<rim:cache maxCacheSizeTotal="2048" maxCacheSizeItem ="256" />


I have also just recently added a preload system, which is working as I can pause the code immediately after it and the images have been loaded into memory. This sits in the <head> of the the file.


		<script type="text/javascript" charset="utf-8">
			var i = 0;     
			imageObj = new Image();      // set image list     
			images = new Array();     
			// start preloading     
			for(i=0; i<=6; i++)     


Help much appreciated as always

Posts: 40
Registered: ‎05-12-2012
My Device: 9800
My Carrier: Virgin mobile

Re: Issues with Caching

It would appear that none of the image files have any cache control implemented. I would have thought BBWP would set these or at least the would get set when the config file is read.


Blackberry peeps, what am I doing wrong. This is very urgent!


Posts: 40
Registered: ‎05-12-2012
My Device: 9800
My Carrier: Virgin mobile

Re: Issues with Caching


OK so I have created a test harness and the same issue applies. Here is the entire site HTML


<!DOCTYPE html>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0" />
   <title>Test Harness</title>

<body id="bodyID" >
		<img src='art/no_photo_small.gif'/>
		<img src='art/no_photo_small.gif'/>
		<img src='art/no_photo_small.gif'/>
		<img src='art/no_photo_small.gif'/>
		<img src='art/no_photo_small.gif'/>
		<img src='art/no_photo_small.gif'/>
		<img src='art/no_photo_small.gif'/>


 And the following config file


<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" 

   	version="" rim:header="Test Harness">

   	<description>Testing App.</description>
   	<content src="index.html"/>
   	<access uri="*" subdomains="true"/>

	<rim:cache maxCacheSizeTotal="2048" maxCacheSizeItem ="256" />

   	<rim:navigation mode="focus" />
    <icon src="blackberry_128test.png" />
   	<feature id="blackberry.app" required="true" version=""/>
   	<feature id="blackberry.system"/>   	
   	<feature id="blackberry.system.event"/>
   	<feature id="blackberry.ui.dialog" />
   	<feature id="blackberry.ui.menu" required="true" version="" />
   	<feature id="blackberry.invoke" /> 
   	<feature id="blackberry.invoke.MessageArguments" />
   	<feature id="blackberry.invoke.BrowserArguments" /> 
   	<feature id="blackberry.message" />



This is not caching the image files. WHY what am I doing wrong. This is super urgent!!!!


Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: Issues with Caching

Question: How do you know its not caching?


You've done everything by the book, just wondering how you know its not caching the images.

If it helped you, click like. Smiley Happy
Posts: 40
Registered: ‎05-12-2012
My Device: 9800
My Carrier: Virgin mobile

Re: Issues with Caching

I use web inspector. There are a couple of reasons why I think/know it is not caching


Fisrtly the memory footprint is growing by roughly the size of the images when more are loaded

When I look at each load the load times are > 0ms which they should not be if they were cached

When I run an Audit it tells me that most of the files are not cached.