0

am sorry for this question, but everyone here is talking about IndexedDB, WebSQL, Local Storage, so my question is simple:

If the application is always refreshing new contents (think Facebook, or an ecommerce website), so does it make sense to use the Offline storage? if yes, then what do i store? the user's files?

Abdelouahab Pp
  • 3,506
  • 11
  • 35
  • 64
  • 1
    Facebook could store your list of friends. An e-commerce site could store which items you've viewed. – Šime Vidas Nov 23 '12 at 20:36
  • 1
    HTML5 local storage is for storing anything that a browser page might want to store on the local user's computer. Because this info is only stored on the local user's computer, it is not available from any other computer that that user might use. It can be used as a data cache, as storage of some user state from one computer, as a temporary storage for access offline, etc... – jfriend00 Nov 23 '12 at 20:37
  • 1
    @jfriend00 I wouldn't be surprised if the browser's sync mechanisms carried local storage data across machines. – Šime Vidas Nov 23 '12 at 20:39
  • yes, the local storage is to avoid requests to server (as i understand), but if informations are small, why not using cookies? pictures are cached using server software without using html5 no? – Abdelouahab Pp Nov 23 '12 at 20:41
  • 1
    @AbdelouahabPp Search on SO, e.g. http://stackoverflow.com/q/3220660/425275 – Šime Vidas Nov 23 '12 at 20:43
  • @ŠimeVidas for example, my case, i'm making an ecommerce application, where i stored some basic information in a cookie, the rest, i request it from the server, and what i want is informations about big data, this is why am interrested in html5, i'm using mongodb for server side db, so is there any good cases for this? cart for exemple? – Abdelouahab Pp Nov 23 '12 at 20:46
  • 1
    @AbdelouahabPp Do you request "the rest" multiple times during one session? (As in on each page load?) If no, where do you keep that data between pages? – Šime Vidas Nov 23 '12 at 20:49
  • the user will do normal search for items, then if an item will be interresting, he adds it to a cart (without buying, no transaction, only something like, buy later in real life, because here in Algeria there is no Payement Gateway). so do i store his cart, to be acessible next time? – Abdelouahab Pp Nov 23 '12 at 20:58
  • 1
    @AbdelouahabPp Yes, you just store a list of all selected items in the local storage object. Then, on each page load, you check the local storage if any items are selected, and if there are, you display them to the user. – Šime Vidas Nov 23 '12 at 21:03
  • then, where is the websql here? am sorry but i cant find any use case for websql? if it's only the cart, so no need to make requests by sql to gain sql advantages? can you please make an asnwer with a method so i validate it, here is says "avoid discussions :'( " .... – Abdelouahab Pp Nov 23 '12 at 21:06
  • 1
    @AbdelouahabPp WebSQL is an abandoned standard, and not implemented in Firefox, or IE. IndexedDB is the database standard that's being developed. – Šime Vidas Nov 23 '12 at 21:10
  • yes heard about it, but i force users to use Chrome and Opera (that's just a project for my thesis, so i made two browsers to make some html5 tests, and how to detect users browser, the thesis is about nosql, and indexdb is an nosql, so am interrested in, can you please provide me an exemple? – Abdelouahab Pp Nov 23 '12 at 21:14

1 Answers1

1

Yes, it make sense.

Suppose, we have a lot of user data and application data. Application data is shared for all users, while user data is private to login user. Two client side databases are used. The data are store in IndexedDB (or WebSQL). As soon as user visits the page, the data is rendered immediately without sending a request to the backend server.

After rendering the page, XHR GET request is sent with If-None-Match etag header. Server will reply with 302 or 200 depending we need to update or not. That saves bandwidth and server load.

nycynik
  • 6,712
  • 5
  • 54
  • 80
Kyaw Tun
  • 10,164
  • 7
  • 44
  • 72
  • so then i must retrieve this data form its first login? and then, what do i retrieve? his cart? and what about saving pictures? why not only telling the server to do the 'old way' to cache them? – Abdelouahab Pp Nov 26 '12 at 10:01
  • 1
    you got to be kidding. first login is pure HTML. – Kyaw Tun Nov 26 '12 at 15:35
  • no, what i want to say: what do i retrieve exactly after the user has logged in? – Abdelouahab Pp Nov 27 '12 at 14:47
  • 1
    once, login, you know the user id. you can retrive database specific to that user id and render everything for the user. – Kyaw Tun Nov 27 '12 at 15:26
  • 1
    you can use 'old way' caching if you can. But it is not easy as database. You can see gmail app, it is not using database, but use 'old way'. see how difficult it is. all go private cache query url iframesssss. client side database reduce server load significantly. – Kyaw Tun Nov 27 '12 at 15:29
  • so then, i'll use his id to get "every thing" and then cache it on the user's browser! so this is the tip? in mongodb i get the user's document and download it all! this will not have drawbacks? sorry because i dont understand well this technology – Abdelouahab Pp Nov 27 '12 at 21:27
  • 1
    right. I am writing a js database library. definitely worth check out http://dev.yathit.com/ydn-db/getting-started.html for your case. syncing will coming for gdata, odata and couchdb. – Kyaw Tun Nov 27 '12 at 23:35
  • so the idea is to make a 'big' call to the server and tell him: give me everything that i need so i'll not ask you again! now the work is how to make relation between technologies: NoSql and SQL ... – Abdelouahab Pp Nov 28 '12 at 09:54
  • 1
    Yes. You don't need backend database, blob store like Google cloud storage may be fine. One good thing about them is they have object-wise ACL. Giving create object right to the bucket to login user, it becomes secure private database. – Kyaw Tun Nov 28 '12 at 14:02
  • ah, now i'm a little bit blurred about this new technologie, i'll stick with what you give me at the moment, and try do my best :) thank you again – Abdelouahab Pp Nov 28 '12 at 15:31