Jump to content

Help Understanding Cacheing


wongadob

Recommended Posts

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. 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>	   		  <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>		  </div>

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. Help much appreciated as always

Link to comment
Share on other sites

Unless you're using a web browser, wouldn't that be a question you should ask RIM?

Edited by niche
Link to comment
Share on other sites

Webworks is a HTML 5 web app system. So yes it should be using browser tech. I have searched all the RIM docs to see if there is anything special I should be doing to. Basicailly you create HTML with CSS & javascript and then build into a java app. It should function as a web site, but is packaged as a JAVA app.

Link to comment
Share on other sites

It does not even mention it. All I can find there is how the config file needs to be set up to control the cache size. Which is all set up to maximums. I have wrttren a pre-loader that should get all items into the cache in advance of any rendering. But that makes no difference. The memory footprint for images still just keeps growing. There is no other art other than these 3 items now on the pages. So there should be no reason for the memory to continually increase other than each instance is being trreated as a unique piece of art. You can see by the code above there is no way the location or name of the file changes so they should be being pulled from the cache.

Link to comment
Share on other sites

If you're talking just about the cache on your machine, try someone else's Blackberry. EDIT: Is there a way to dump your cache at the beginning of each run?

Edited by niche
Link to comment
Share on other sites

I have discovered that the images do not have an expiry date set so are not getting placed into the cache. Problem I have now is finding out how to set their HTTP header info to have expiry information. If this was a standard website I know I can just set up the .htaccess file which would set default expiries for cetrain file types. But this is a webworks webapp. I have been through every bit of documentation I can find, but the only relevant thing I can find is this line that has to be in the config file <rim:cache maxCacheSizeTotal="2048" maxCacheSizeItem ="256" /> The only other attribute is - The aggressiveCacheAge attribute specifies the amount of time, in seconds, to cache items that are not governed by directives in the HTTP header.By default, if you do not specify this attribute, these items are kept for 2592000 seconds (30 days). Settings higher than this value are ignored. This attribute is optional. I have tried adding it but it makes no difference. So here I am still stmuped. Been on this one problem for 2 days now.

Edited by wongadob
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...