Tuesday, August 28, 2012

Optimize performance of Applications developed in ExtJs 4 or Sencha 2: Web Storage & Sqlite

Storing Data on Client side:
We can enhance our web application response time by storing less modifiable data on our client machine. If we do this, we can minimize server hit for these data and thus can minimize the response time to a great extent.
For storing data on client side, now a day, mainly two type of storages are being used.
1)      Web Storage
2)      Some client side Relational Database like Sqlite
Web Storage:
Web storage is standardized by w3c. Web Storage can be viewed as improvement on cookies. It differs from cookies like:
·         Web Storage provides greater storage capacity ( 5 mb per domain in Mozilla, Chrome, Opera and 10 mb per storage area in IE) compared to 4 kb for cookies.
·         Unlike in case of cookies, which can be directly accessed and changed by server programming,  web storage cannot be directly altered by Server programming.
There are two main web storage types: localStorage and sessionStorage.
localStorage:
 The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year. Here, data is stored like a key-value pair. E.g.
// Store value on the browser beyond the duration of the session
localStorage.setItem('key', 'value');

// Retrieve value (works even after closing and re-opening the browser)
alert(localStorage.getItem('key'));

Session Storage:

The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the browser window.

// Store value on browser for duration of the session
sessionStorage.setItem('key', 'value');
 
// Retrieve value (gets deleted when browser is closed and re-opened)
alert(sessionStorage.getItem('key'));


SQLite:

SQLite is an embedded SQL database engine. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. SQLite is a compact library with library size of 350 kb when all features are enabled. SQLite can also be made to run in minimal stack space (4KiB) and very little heap (100KiB), making SQLite a popular database engine choice on memory constrained gadgets such as cellphones, PDAs, and MP3 players. Important features of Sqlite are as follows:

Important Features:

1)      Zero – Configuration: There is not any installation and configuration process for Sqlite to use it. It can be directly used.
2)      Server Less:  It is not implemented as a separate server process. With SQLite, the process that wants to access the database reads and writes directly from the database files on disk. There is no intermediary server process.
3)      Single Database file: An SQLite database is a single ordinary disk file that can be located anywhere in the directory hierarchy.
4)      Stable Cross-Platform Database File
5)      Compact
6)      Menifest Typing
7)      Variable length records
8)      Readable source code

Detail Ideas about SQLite can be found from http://www.sqlite.org.

No comments:

Post a Comment

Please provide your precious comments and suggestion