Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 988395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:37:52+00:00 2026-05-16T05:37:52+00:00

We are building web applications for the iPhone that work offline. But we are

  • 0

We are building web applications for the iPhone that work offline. But we are having difficulties caching dynamic images. Please read on and I’ll show by example exactly what I mean and what we have done so far.

So for example let’s say we are building a simple list application with just 1 page. The application’s only purpose is to list 5 items, each item containing some text and 1 image.

The application has a simple logo and some separate JavaScript and CSS code. These static resources are cached using the cache manifest file.

There are 2 scenario’s:

Scenario 1: I’m online and I open up the web application

When I load the list application in Safari it will fetch 5 new random items out of a database containing 1000’s of items. These are all served by simple backend through a AJAX call (JSON format).

The whole JSON object containing the 5 items is immediately stored in HTML5 local storage and cached for offline usage.

Structure of the JSON object is a bit like this:

{
    "0" : {
        id: "3",
        text: "Some text about item #3",
        image_url: "http://www.domain.com/image22341.png"
    },
    "1" : {
        id: "23",
        text: "Some text about item #23",
        image_url: "http://www.domain.com/image442321.png"
    },
    "2" : {
        id: "4",
        text: "Some text about item #4",
        image_url: "http://www.domain.com/image2321.png"
    },
    "3" : {
        id: "432",
        text: "Some text about item #432",
        image_url: "http://www.domain.com/image2441.png"
    },
    "4" : {
        id: "43",
        text: "Some text about item #43",
        image_url: "http://www.domain.com/image221.png"
    }
}

As you can see, very simple (may be some errors in that JSON), the whole JSON object is stored in local storage.

Now the 5 items are rendered using JavaScript injected HTML (styled using CSS), nothing fancy. Span tags containing the text and image tags pointing to the image resource are created etc.

In online mode, it all works great.

Scenario 2: I’m OFFLINE and I open up the web application

The page loads (the logo is displayed because it was cached as a static resource using the cache manifest), some JavaScript detects that we are indeed offline and the application as a result does not attempt to contact the backend. Instead it reads the previously stored JSON object from local storage and commences rendering the 5 items. All as anticipated.

Text is displayed fine, but this time, the images are not displayed, reason for that is simple, the image tags are pointing to image resources which are not available. So it displays that little image not available icon.


Now my question is, is there any way to cache those image resources somehow? So that next time we need them, they are fetched from cache.

This is what I’ve tried:

  • Base64 encode the images and supply them through JSON. This works BUT, it dramatically increases both fetching and rendering time (we are talking about 30 seconds increase, very slow)
  • Some cache manifest hacking/trial and error.. couldn’t find anything that works (ideally need a policy that does ‘cache all resources on domain as they are requested’, but to my knowledge this does not exist)

I have literally spent hours on this and can’t find a solution… does anyone have a clue? I know this is possible because if you look at the Google Mail HTML5 application for the iPhone, they can somehow cache the attachments and you can retrieve them even while offline.

The one thing we haven’t tried is using the SQLite databases that are supported by Safari… maybe I could store the images as a BLOB (still means fetching it from the feed and thus slow?) and then somehow magically converting that into an image on the screen…. but I have no idea on how to do this.

Any help is appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:37:53+00:00Added an answer on May 16, 2026 at 5:37 am

    I would advise you to take a look to see if you can use canvases to hold your images, as they have certain properties to get/insert image pixel data, such as a CSV of pixel values (0-255).

    Source: https://developer.apple.com/library/content/documentation/AudioVideo/Conceptual/HTML-canvas-guide/PixelManipulation/PixelManipulation.html

    I’m not sure if you can dynamically use image sources into a canvas but if you can you should be able to transfer the CSVV data from the image to a DB and visa versa.

    Quote

    Safari 4.0 and later support direct manipulation of the pixels of a canvas. You can obtain the raw pixel data of a canvas with the getImageData() function and create a new buffer for manipulated pixels with the createImageData() function.

    (source on archive.org)


    Update:

    I found this links you may also be interested in.

    http://wecreategames.com/blog/?p=210

    http://wecreategames.com/blog/?p=219 //Also note the idea with canvas serialization 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a programming language suitable for building web applications, that is compiled, strongly-typed,
I am trying to coach some guys on building web applications. They understand and
I've been building .NET web applications for many years now, and I never use
I'm building a web application that guides my users through the configuration and installation
I am building a web application that uses the database for Users, Security/roles, and
I am building a web app targeting the iPhone. It is similar to a
I am interested in building web applications using Ruby on Rails. I surfed the
I am building a web application that uses a lot of Javascript. Now I
We are building a corporate web application that needs to run on every device
While building web applications I'm wondering how long of a secret I need (how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.