dukecon / dukecon_html5

MIT License
2 stars 3 forks source link

Improve performance #22

Closed annam002 closed 8 years ago

annam002 commented 8 years ago

Performance has been reported to be poor sometimes, especially in Firefox. Analyse the possible sources of performance problems and eliminate them.

annam002 commented 8 years ago

Possible performance culprits

annam002 commented 8 years ago

Optimize loading

The data should only be loaded from the server when necessary. Currently, I implemented a timeout - the data is valid for two hours. After that, the data is reloaded from the server and the timeout is reset. This is still suboptimal:

annam002 commented 8 years ago

Offline detection

It is difficult to detect the online/offline state of the browser. There is an API in HTML 5 for this, but it is not consistently implemented across browsers. The safest bet seems to be to listen for the status of the appcache file load and set an offline flag when the appcache file cannot be loaded: http://www.html5rocks.com/en/mobile/workingoffthegrid/#toc-appcache

I implemented this, but unfortunately, the offline flag can only be set after the page is already loaded. Therefore, I store the offline state in the local cache, so that from the second time the app is loaded in offline state, it does not try to connect to the server.This also means that when the app goes online again, the app is in offline state on the first load. If we had https://github.com/dukecon/dukecon_server/issues/30 implemented, it could be an idea to check for data refreshes at this point and reload the page.

annam002 commented 8 years ago

Implemented a regular check for server updates based on the newly built etag-hash-information.

annam002 commented 8 years ago

With the actionstaken, performance seems to be a lot better, so closing the issue for now.