Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Using WebSockets to keep a local cache in sync

Sunday, February 9, 2014

Introduction

Every now and then you find yourself in a situation were you have to make the most out of the few resources you have available - at least I did!

One of my projects was having considerable performance problems, problems I realised were mainly due to a very slow network - it could take something between 2 to 5 seconds to retrieve 300kb, something that was causing a really sluggish user experience.

Given that the client didn't want to move his server for is current hosting provider, but was complaining all the time of how slow things were, I realised that I had to find a way to improve application responsiveness by having the data already stored locally when the user/UI actually needs it.

So, devised a strategy of keeping a local cache and using web sockets to notify my local cache that local data as dirty and needs to be updated.