Search code examples
service-workerprogressive-web-appscacheapi

PWA offline capability on data that frecuently changes


Are Progressive Web Apps offline capability a good idea on applications that display data that change frequently like a bank account balance?

If The user is using his PWA offline mode and navigates for example to the bank product balances section he is actually viewing no updated data about his balances and allowing to make operations based on a data that may not be updated.

Do I miss something about this approach (PWA) on data that frequently changes?


Solution

  • PWA doesn't mean you capture the entire page. As a developer, you choose what you want to cache. Two type of cache can be done.

    1) Static content cache aka App shell cache - like your HTML/CSS/JS and image files. This can be refreshed using service worker when the change(will happen in the background without user needing to do anything). This is something which can be done even for sites like bank transaction page.

    2) API data cache - This is where you cache the dynamic data like JSON response from your web service. Even this can be implemented for bank transaction page, if displayed the information responsibly. Say on top of the transactions, you can display a message "Transactions as of June-6th-2018 5.11PM" in a nice prompting way so user knows he is not seeing real-time data, but he/she might be happy to see the old transactions if thats what he is looking for.

    Or you can completely ignore to cache dynamic data like API response or server rendered HTML which has such dynamic data and cache what is static only.

    End of the day, its you as a developer who decides what to cache and caching something will give you improvement over no cache even in such dynamic content site.

    Here is a Google's doc on explaining both.