0

I'm building a HTML5 recipe app. As a user browses through recipes, they should be able to save the recipe as a favourite for offline browsing. That would mean saving a photo gallery in the recipe as well.

Given I can't know ahead of time which recipe a user will select, I can't add the appropriate images to the cache manifest. What would be my best option? I'll use WebSQL if I must, but I use it judiciously given it will someday be replaced. Is there a strategy I could employ that leverages local storage perhaps? Anyone know of an example?

Thanks!

Chris

Mister Epic
  • 16,295
  • 13
  • 76
  • 147
  • 1
    You can generate the manifest file dynamically. Save a list of favourite recipes in a cookie/session, use server side programming to compile a list of files for the manifest based on that saved value. Trigger a cache refresh through JS afterwards. (Beware of cache size limitations...) – DCoder Mar 10 '13 at 15:25
  • Hmm, interesting strategy. The downside would be everything in the cache manifest would be downloaded every time a recipe is added to favourites. This is going to be a mobile app, so I need to be cognizant of the bandwidth used. Might not be an issue, I'll have to finish the app to see how much data would get pushed down the pipe :) – Mister Epic Mar 10 '13 at 15:37
  • 1
    If your files are set up with the proper lifetime/caching headers (as they should be), only the changed files will be downloaded on each manifest change. – DCoder Mar 10 '13 at 15:39
  • Really? I didn't know that, I'll have to play around with that. – Mister Epic Mar 10 '13 at 18:50
  • And if you submit this as an answer, I'll make it as correct. – Mister Epic Mar 11 '13 at 12:19
  • Possible duplicate of [IndexedDB very slow compared to WebSQL, what am i doing wrong?](http://stackoverflow.com/questions/10102571/indexeddb-very-slow-compared-to-websql-what-am-i-doing-wrong) – Paul Sweatte Sep 28 '16 at 08:10

0 Answers0