Tag: Javascript

Update cache with ServiceWorker

There are many examples of updating the cache of a service worker, but they all assume you want to create a new cache. Most of the time, you only want to update just 1 or 2 files, like a stylesheet and some javascript file. A simpler approach for this is to just use the same […]

HTML5 history

For a web application I am developing (Courser) I need to control the history. The application can run in a browser but also as a "standalone" web app in Chrome and Safari. As a standalone app you have no navigation buttons, but I wanted to make the Android Back button work like expected and the […]

Catch errors in Promise

When using the static resolve() Promise method, you often see code like this: Promise.resolve(func()).then(function(result) { console.log("Ok for: " + result); }).catch(function(error) { console.log("Error: " + error); }); console.log("Some code running after Promise.resolve..."); Everything is ok when the func() function has no errors: function func() { return "OK!"; } Output: Some code running after Promise.resolve... Ok […]

UTC date in javascript, php, mysql and sqlite

It can be very challenging to work with dates and times across different timezones. In this post I explain some of the things I do to make this work. I focus on Javascript, PHP, MySQL and SQLite development. MySQL The most important action first - put the connection session in UTC mode: set time_zone = […]