Jordan T. Cox
Jordan T. Cox

Reputation: 332

Preventing Mobile Safari Cache Overflow

I've got a simple little web app that's aggregating a couple views from some ethernet enabled cameras around my house. This is basically a little dashboard, so that I can easily tell what's going on around the house. I've got it refreshing the images every so often by appending new Date().getTime() to the base URI.

Everything works happy days, except for one little issue. If I leave the dashboard up on my iPad for awhile, it runs out of memory and crashes back to the home screen. I know that its because Mobile Safari is caching each of these images in RAM and it eventually ends up with far too many of them.

Since these images are being hosted on embedded devices; I really have no ability to modify the caching headers directly. I would like to stay away from making a wrapper on my server side as well.

My question is; can anyone think of a way to prevent Mobile Safari from caching these images so aggressively that it crashes?

Upvotes: 1

Views: 1113

Answers (1)

Amir
Amir

Reputation: 4151

You might try to reuse your img tags and/or set the src attribute to an empty string before removing an image. It's probably not an aggressive cache that's crashing mobile safari, but how the browser doesn't deal well with releasing image references when image tags get deleted.

You might find more useful information here: http://www.vargatron.com/2010/08/ipad-html5-js-memory-management/

Upvotes: 1

Related Questions