Auto Suggest for very slow internet connections - e-commerce

I have an auto suggestion mechanism that works fairly nice for desktop version where we have a wireless or a wired internet connection. The worst response time is 320ms.
(Without using solr as of now, I use a storage system on the server that gives back the result).
I have users that belong to the group where you can have a slow internet connection also known as a 2G connection where the downspeed can be ~10Kbps-50Kbps.
I have seen that google provides Auto Suggestion to this speed as-well, my my system cannot.
I have tried these:
Make a txt and JSON file on the server and when the user does a keydown (1st) it fires ajax to bring the entire 2.2MB data inside a JS variable on client side and show suggestions.
Make a service that is called when the user types 2 characters, service reads the txt/JSON file for those 3 character occurence anywhere in the words and gives data into a JS variable.
Repeat the above step and store the result in localStorage, for a fresh 3 characters again the same process occurs and storage happens. The benefit is that the user in future gets a prompt suggestion but according to me browser storage is used very sensibly.
Anyone with suggestions how www.google.com and www.flipkart.com handles auto suggestions for slow internet connections on mobile (smartphones).

Related

Saving data on phone in a Cordova app

I am making a mobile app using Cordova and I need to save some sensitive and not so sensitive data inside the phone. I am a bit lost on what is the best way to do it.
I need to save:
A JSON web-token (for authentication).
A response from server (I save this to populate my page in case the GET request fails).
Coordinates information when user is logging data to the app (for later upload to a server from with in the app). These will be many separate logs, and can be large in size for local storage ~5-10 MB.
Till now i have been successfully saving everything I need to the local storage but I don't think that is the correct way to do it. So that is why I need some help in deciding what is the best course to take from security point of view.
Saving server response is just for better UI experience and static in size so I guess local storage is a good option to use.
But web-tokens and GPS logs is sensitive information and I dont want to keep it in the local storage as it is accessible from outside the app.
What other options do I have?
Cordova still doesn't have encrypted storage.
Is saving to files a good approach? This here says that data contained inside cordova.file.applicationStorageDirectory is private to the app.So can I use it to save the logs and the token?
The plugin also lists the file systems for Android and iOS and lists which of those are private.
I am currently working with android phones but want to extend the app to iOS later. I have never worked with file systems and caches before so I am a bit lost.

output to a web site from winforms app

I have an winforms VB application that outputs a string of characters to a serial port and it goes through RS232 port to another computer and writes to a portal on the other computer -- I'm not sure if it writes one character at a time or the whole string. At any rate, there is a device between the 2 computers that emulates a keyboard input.
The character (or string or characters) is output wherever the cursor has focus on the other computer. I'm not sure whether I'm explaining this clearly, but the basic idea is to automate the typing of data into a web portal (it works very well).
However (to make a long story short), the goal is to eliminate the second computer, using extended dual screens. The application and the web portal would be open on the same computer (instead of 2) and output from the winforms application would be directed to the web portal and written where the focus is on the web portal.
The way that I imagine it should work is like this: a process would write text to a stream, but instead of redirecting the text to a file or the console, it would write it to wherever the cursor's focus is.
My question is what method could I use to do this? I've been looking into the ProcessStartInfo Class, but I'm not sure if I'm on the right track.
Any help would be sincerely appreciated.

Uploads restarting indefinitely if they fail - Will it happen on 3G/4G

Is there a way to prevent BackgroundTransfer from trying indefinitely to upload a file. Let's say one of my user is trying to upload a movie from the phone to Facebook. Facebook Graph API doesn't accept byte-range/resume/etc. Let's say the network is slow, less than 50 kbps. Under 50 kbps, BackgroundTransferService will restart the upload.
That being said, when testing my app, I've noticed that the uploaded restarted 4-5 times under my very slow 3G wifi router (yeah... I'm a mix of the two cases).
Will this behavior happen on a GSM/3G/4G network?
What think is that this behavior is totally welcome, on a Wifi, but not on a phone network, as data costs more.
[Edit]
I forgot one important info: I don't have internet on my WP, so that's why I ignore the behavior of BTS on a phone network.
Yes, the agent will try and reattempt the transfer if the connection is dropped. This is one of the benefits of using the agent, you let it worry about reattempting and network conditions so you don't have to. The API does all you a level of control over usage of cellular data via the TransferPreferences property. You could set this if you're concerned. Alternatively, let the user set their own preferences about data usage via the built in settings on the phone.
There is more information at http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202955(v=vs.105).aspx#BKMK_TimelinessofCompletion

Collecting Stats

I'm writing an application for the Mac App Store in Obj-C/Cocoa. The app processes .html files and does not require an internet connection.
I was wondering, what would be the best way to collect statistics? All I'm interested in is the number of files processed.
That way, on the app's home page, I can display XXX,XXX files processed.
I was thinking that I would just post to a web server whenever a file was converted, but that would considerably slow down the app and wouldn't work if the user was not connected to the internet.
You could accumulate the stats internally to be uploaded only every so often (each day, perhaps). You'd save the accumulated number across restarts using NSUserDefaults.
You should ask the user for permission to upload data, even something so seemingly innocuous as a count of processed files.
You'd use a simple HTTP request to upload the data. (You know it will be vulnerable to spoofing, right?) You should use the network reachability API to check whether the system is network connected before trying, so you don't force a dial-up, for example. The reachability API can't tell you that your connection will for sure succeed, so you should handle failure to connect gracefully.

Synchronizing of user's browser refresh

I did comprehensive Google research but I cannot find any good solution, so any help (or just showing direction of next research) would by REALLY appreciated!
What I need is simple in idea, but looks like hard to implement:
I have data (say just picture) I want to show to all (even anonymous) users of website in the very same time. This data should change regularly (say once in 5 minutes), so the browsers of all users must refresh in given time.
The woflow is simple:
User will open page with countdown (which will show of course different time for each user depends of when the user has had connected).
At the end of countdown shall all browsers of connected users refresh to see new content.
The refresh should be ideally invoked by server to prevent prematured refresh when data doesn't changed yet.
I was thinking of "refresh" meta tag, but it is problematic for SEO and it rely on user computer's clock.
It can be done by javascript, but in that moment I rely on user computer's clock.
I have hearded it is possible "push" data from server to browser using e.g. Perl, it is correct (is there somewhere some example)?
And in which scripting language would you write script which would "tick". I cannot see way in PHP I am familiar with (use cron to execute counting script every minute looks really ugly)...
Thank you!
Michal
It's not possible to push data from a web server to a web brower, given the request-response architecture of HTTP. It is, however, possible to poll the webserver using JavaScript and window.setInterval(); combined with AJAX.
If not using local system time is an issue, why not respond to periodic AJAX requests with the number of microseconds until the next reload of data should commence? I would suggest you use AJAX for all of this instead of refreshing the browser with META REFRESH, or window.location.
The server-side code could be anything really, you simply need a page that will return the number of microseconds until the next schedule refresh (And perhaps an error if no refresh is scheduled yet, telling the client JavaScript to poll again in a few seconds).