@misprintedtype COOL, WHAT NOW? IM OFFLINE - we <3 GOTOBerlin - - - PowerPoint PPT Presentation

misprintedtype
SMART_READER_LITE
LIVE PREVIEW

@misprintedtype COOL, WHAT NOW? IM OFFLINE - we <3 GOTOBerlin - - - PowerPoint PPT Presentation

@misprintedtype COOL, WHAT NOW? IM OFFLINE - we <3 GOTOBerlin - Hello there! How are you? Are you tired or still good ? Did you enjoy your first day so far? Cool! Okay So, lets do this. Welcome to my talk about best practice in offline


slide-1
SLIDE 1

@misprintedtype

slide-2
SLIDE 2

I’M OFFLINE

COOL, WHAT NOW?

  • we <3 GOTOBerlin -

Hello there! How are you? Are you tired or still good? Did you enjoy your first day so far? Cool! Okay… So, lets do this. Welcome to my talk about best practice in offline first and the learnings we gathered in the past few years.

slide-3
SLIDE 3

OLA GASIDLO

Lead Developer Co-Organizer CSSConfEU

My name is Ola Gasidlo. I am a lead developer at Styla, Co-Organizer of CSSConfEU and organizer of various conferences and meetups and even more… Today I’d love to tell you a bit about the actual state of offline first, how our point of view changed in the past few years and how its adapting to the real world.

slide-4
SLIDE 4

@misprintedtype

Trigger Warnings

death / pandemic animated gifs

Before I start, I’d like to mention in this talk I’ll speak a pandemic and death, but there won’t be any kind of graphical display of those topics. Plus there will be animated gifs.

slide-5
SLIDE 5

@misprintedtype

Trigger Warnings

death / pandemic animated gifs

So, if you’d rather leave, because you won’t feel comfortable with this content… I fully understand. I am happy to chat with you after the talk and give you a summary of the content. You still have time to leave, if you’d like to until the first gifs. Let’s start then.

slide-6
SLIDE 6

@misprintedtype

The internet, it turned 25 this year. Amazing times we all live in…

slide-7
SLIDE 7

@misprintedtype

In this time, our relationship with the internet changed. A lot. We do different things, with different devices than 25, 10, 5 years ago... and it is a part of our everyday life! We rely on our devices... the internet, but our needs changed.

slide-8
SLIDE 8

@misprintedtype

Three years ago, when the Offline First movement got broader attention, I gave my first talks about the concept. That was in twenty-thirteen. What was our idea back then…? Why did we need the offline first concept so badly?…

slide-9
SLIDE 9

@misprintedtype

First thing was the rise of the mobile devices and their usage. There are countries, where people do not even use desktop devices at all anymore. When you think about how cheap a phone is in comparison to e.g. a laptop, it totally makes sense, right? A mobile device is mostly enough, if you consider what the user needs it for.

slide-10
SLIDE 10

@misprintedtype

There was also the issue of no constant connectivity or poor network coverage. Here offline first felt like a huge enhancement to your application and adaption to our new behavior.

slide-11
SLIDE 11

@misprintedtype

Three years later, in twenty-sixteen, what do you think..? Do we still need the offline first concept?

slide-12
SLIDE 12

@misprintedtype

TELL ME…

Tell me… (by raising your hand)

  • Who of you are already building offline first applications?
  • Who of you thinks, they are following the correct approach to make their applications Offline First? (There is still no perfect path… We are still trying to figure this one out.)
  • Who of you thinks about Offline First as progressive enhancement?
slide-13
SLIDE 13

@misprintedtype

After seeing offline first in the wild, we’ve realized… it’s not just about a special use case or rise of the mobile devices. It’s about the whole approach… It’s so much more.

slide-14
SLIDE 14

„OFFLINE FIRST“ MEANS GETTING ON SCREEN WITHOUT A NETWORK REQUEST…

Jake Archibald @twitter

As Jake Archibald once said… „Offline first“ means getting on screen without a network request…

slide-15
SLIDE 15

…THE MORE THAT’S THERE BEFORE THE NETWORK, THE MORE OFFLINE FIRST IT IS.

Jake Archibald @twitter

…The more that’s there before the network, the more offline first it is. This means, every web app should work without a connection after the first visit and just use the network for getting / setting new data. Everything else is online-first.

slide-16
SLIDE 16

@misprintedtype

PWA?

Remember me asking you if offline first is a progressive enhancement to your application? Like 3 slides ago?
 
 What if I tell you, you are actually…

slide-17
SLIDE 17

@misprintedtype

WRONG

…wrong! -> 1, 2, 3 This might sound confusing… Why is the offline first concept not progressive enhancement? Actually it is the other way around… Let’s take a step back and see, why do we need applications?

slide-18
SLIDE 18

@misprintedtype

WHY?

Normally we use applications for our everyday life, to make our everyday life easier, right? Like…

slide-19
SLIDE 19

@misprintedtype

Checking in with family members and other loved ones abroad or maybe just text your partner during the day.

slide-20
SLIDE 20

@misprintedtype

Using Slack, IRC etc. at work, especially in remote teams.

  • > it all comes down to…
slide-21
SLIDE 21

@misprintedtype

COMMUNICATION

  • > communication
slide-22
SLIDE 22

@misprintedtype

We also need applications for tracking data. Did I drink enough during today? How many steps did I make? How much money did I spend this week? But also…

slide-23
SLIDE 23

@misprintedtype

How can I fix my bike or my washing machine? How do I translate this or even… „Did I spell this right?“

  • > basically it’s about
slide-24
SLIDE 24

@misprintedtype

COMMUNICATION INFORMATION

  • > information
slide-25
SLIDE 25

@misprintedtype

Posting selfies from your last vacation, tweeting your thoughts etc. Checking in symptoms when you are sick…

slide-26
SLIDE 26

@misprintedtype

Or even check the internet why your kids act out.

  • > this is about
slide-27
SLIDE 27

@misprintedtype

COMMUNICATION INFORMATION EMPOWERMENT

  • > empowerment

AND… most important thing…

slide-28
SLIDE 28

@misprintedtype

cat.gifs… (1… 2… 3…)

  • > Which is a basic life need. I think, we all can agree on that. We sum this one up as
slide-29
SLIDE 29

@misprintedtype

COMMUNICATION INFORMATION EMPOWERMENT LOVE

—> love. So, when we look at those points… Communication, information, empowerment and love, this all sounds like something we all have in common right?

slide-30
SLIDE 30

@misprintedtype

When we break it down, it all comes down to help satisfy our very basic, humane needs for safety, belonging, esteem and self-actualization. Maslow defined all those points in his „Hierarchy of needs“ already in nineteen-fourtythree.

slide-31
SLIDE 31

@misprintedtype

COMMUNICATION INFORMATION EMPOWERMENT LOVE

So since when is helping people to fulfill basic needs, progressive enhancement?

slide-32
SLIDE 32

@misprintedtype

// drauf zeigen… sounds familiar right? But we love to sell it that way, so developers jump on the progressive enhancement train and just redo their apps every 6 weeks in the new, cool framework or

  • whatever. Without knowing what the real issue is…
slide-33
SLIDE 33

@misprintedtype

// drauf zeigen… nech? To be honest… I am so tired of half done applications, which are released out in the wild without any kind of documentation, because someone wanted to refactor their app in the „new cool stuff"…

slide-34
SLIDE 34

@misprintedtype

// drauf zeigen… -> show quotation marks… Or super slow apps, b/c of bad planing and messy architecture.

slide-35
SLIDE 35

@misprintedtype

RETHINK! We do not need a new UBER or Twitter… REALLY. Trust me! We tend to forget that THIS, our JOB is all about humans, people… not frameworks, tech or a design pattern, or the discussion about semicolons.

slide-36
SLIDE 36

@misprintedtype

Don’t build a town, when you need a house. Just because you can!
 
 Especially because usually you end up with the „Gorilla Banana Problem“.

slide-37
SLIDE 37

„YOU WANTED A BANANA BUT WHAT YOU GOT WAS A GORILLA HOLDING THE BANANA AND THE ENTIRE JUNGLE.“

Joe Armstrong

  • > read quote

The Gorilla / Banana problem: Every time you use a whole infrastructure like a framework to solve one problem, you get all this implicit environment that they carry around with them. It’s about using the right tool for a job. Without building a town, when you just need a house. Just because you can.

slide-38
SLIDE 38

@misprintedtype

COMMUNICATION INFORMATION EMPOWERMENT LOVE

It’s all about keeping things simple, but solid. Basic, but optimized. This is why I think, putting offline first in the progressive enhancement slot is pure BS.

slide-39
SLIDE 39

@misprintedtype

Do you know, what the progressive enhancement part of your application is? The network. 
 You might ask yourself… Why should I care? My apps are working…

slide-40
SLIDE 40

@misprintedtype

Are they? (1… 2… 3…) Ever checked your application without or with a bad connection?

slide-41
SLIDE 41

@misprintedtype

How productive are you when e.g. just one service like GitHub is down? Not to mention the office WiFi? How easy is it to communicate with your friends at a concert, when everyone is sending a live stream of the concert via their phone?

slide-42
SLIDE 42

WEALTHY WESTERN WEB

Bruce Lawson

And besides us - with good connectivity situation blessed people, there are others…

slide-43
SLIDE 43

@misprintedtype https://speakerdeck.com/benschwarz/vanity-performance-metrics-looking-beyond-the-numbers

Just 43% of the population has access to an internet connection. And just a small amount of them to a fast and steady one.

slide-44
SLIDE 44

@misprintedtype https://speakerdeck.com/benschwarz/vanity-performance-metrics-looking-beyond-the-numbers

And data is expensive… As you can see here on this list from Ben Schwarz’s talk about performance metrics. Germans would have to work less than one hour for 500 MB, but people in India about 17 hours…

slide-45
SLIDE 45

500MB PER MONTH

Bastian Albers

Let’s assume you have a 500MB plan…

slide-46
SLIDE 46

2,4MB AVERAGE PAGE SIZE = 6,94 SITES/DAY

Bastian Albers

So you could visit almost 7 sites per day during that month.

slide-47
SLIDE 47

~22MIN 720P VIDEO

Bastian Albers

Or watch 22 minutes of talks… So basically ONE talk per month and your data would be gone.

slide-48
SLIDE 48

TENS OF THOUSANDS OF EMAILS

Bastian Albers

https://www.whistleout.com.au/MobilePhones/Guides/Mobile-broadband-usage-guide

Or you could make your others really happy and finally write ALL the mails that you are procrastinating… Without attachments of course.

slide-49
SLIDE 49

@misprintedtype

Our applications should provide the base and work offline per default. The network is the one to enhance our application with new, outside data.

slide-50
SLIDE 50

@misprintedtype

No matter which technology stack we use… Peer-to-Peer network, direct connection to the server or a USB-Stick, whatever works to transfer the data. It’s not important HOW you transfer the data or application on a device. What is important is, we have saved it all locally and enhance the sync through the network.

slide-51
SLIDE 51

@misprintedtype

the REAL world

Not sure, this is true? Let’s check out what is happening in the real world and how others solve their offline issues.

slide-52
SLIDE 52

@misprintedtype

the Router

Let’s start with… the Router…

slide-53
SLIDE 53

@misprintedtype

https://ingevald.files.wordpress.com/2009/02/sweden-river-fog-morning-looking-at-sun.jpg

Imagine… A beautiful morning. You’ve decided to work remotely and are sitting in an „internet cafe“. You’d love to check your mail? Cool! Connect your laptop to the router. Open your email app and send the request to get your mails. Close the laptop and come back in the evening… wait, WHAT!? Why you might ask?

slide-54
SLIDE 54

@misprintedtype

https://ingevald.files.wordpress.com/2009/02/sweden-river-fog-morning-looking-at-sun.jpg

Well… There is no „physical“ connection to the internet like a cable that the internet cafe is using. They just have a router that saves your request and connects via bluetooth to a…

slide-55
SLIDE 55

@misprintedtype

bus! It syncs the requests and off it goes. Literally. The bus arrives at a stop after half of the route to the hot spot with physical connection and syncs with another bus. Also exchanges not just the data, but also the passengers and luggage.

slide-56
SLIDE 56

@misprintedtype

The buses sync via bluetooth previous requests and results. Both buses return. Literally and yeah… you get your emails.

  • Hopefully. If you were able to authorize.
slide-57
SLIDE 57

@misprintedtype

(SNC - Service) Using NAT zones, DTN routing && DakNet network. Saami Network Connectivity

The tech behind the SNC Service is a combination of NAT zones, DTN routing and the DakNet network. (Not to be confused with the DarkNet.)

slide-58
SLIDE 58

@misprintedtype

Learnings (requests & assets)

So, what are our learnings here?

slide-59
SLIDE 59

@misprintedtype

Check your requests!

Actually check your requests, because beside you should be aware of what your are actually doing… Do you need 20 requests or would actually just 2 be enough? Please serve uglify and minified files. Do you really need that 5MB background image on mobile?

slide-60
SLIDE 60

@misprintedtype

beware of Lie-Fi

You should be aware of Lie-Fi, which is the state, where your device checks your connectivity situation, assures that you are online (pinky promise), but there is actually no data passed through.

slide-61
SLIDE 61

@misprintedtype

data queries with bandwidth?

We could go with checking the bandwidth after the very fist ping right? 
 Yes, that could be a thing! And we could develop something similar to media queries and device sizes but just with bandwidth. So we can load assets per detected TRUE bandwidth.

slide-62
SLIDE 62

@misprintedtype

Great idea, right?! But the bandwidth can differ per request, even per package, especially when you are moving, so e.g. are on a train.

slide-63
SLIDE 63

@misprintedtype

data queries with bandwidth

We would need to ping not just per every request, but constantly. You can’t rely on requests to come back. Please add a timeout to kill your request or make the app work fully independent of requesting data.

slide-64
SLIDE 64

@misprintedtype

enhance assets with network

This is why we need to separate updating cycles of the assets and the data. The update of assets is less important than actually syncing data.

slide-65
SLIDE 65

@misprintedtype

save basic set of UI locally

Save a basic set of your UI assets locally (to go easy on your storage). Enhance it with e.g. web fonts, images etc. Whatever you need… Offline should be the default state and we need to make the bandwidth assumption by the device we detect.

slide-66
SLIDE 66

@misprintedtype

keep the caches clean

Take responsibility for the caches and keep them clean. What could be better to use to manage your caches, than Service Worker. No intro in Service Worker today. Sorry. Just one thing…

slide-67
SLIDE 67

@misprintedtype

If you want to use the AppCache for quite a bit, because browsers are dropping the support hard, but also for migration from AppCache to ServiceWorker, please check out the JakeCache.

slide-68
SLIDE 68

@misprintedtype

SVG over IMG

Images… Hard to deal with within the offline context… Saving images in the in-browser storage? Good way to go, but it is still very painful because of storage limitations and very different storage limit implementations. Porting decorative images, like icons and logos to SVG and CSS is a great way to go to cut off a bit of the overhead.

slide-69
SLIDE 69

@misprintedtype

base64 over IMG

Encoding assets in base64 and storing the String in the in-browser storage of your choice could be a way to go. For example, saving fonts like that and loading them straight from the storage, improves the performance a lot. This is even possible for images, like a logo. But please, just do not do this for all of your images. Don’t build the town, build the house. Remember? The strings are huge as we all already know. And in-browser storages are is limited.

slide-70
SLIDE 70

@misprintedtype

base64 is expensive && heavy

Also decoding base64 on the fly is a heavy task. So it slows down your site. Especially in combination with DOM-manipulating frameworks like React. You’ll also find yourself running into race conditions here.

  • > drink

Let’s check out the next use case… It is a bit heavier, as already mentioned. Just to let you know in advance.

slide-71
SLIDE 71

@misprintedtype

the Pandemic

  • > the Pandemic
slide-72
SLIDE 72

@misprintedtype

Twenty-fourteen and twenty-fifteen, the ebola pandemic in parts of West Africa was a really scary issue.

slide-73
SLIDE 73

@misprintedtype

I was involved in a project by the NGO eHealth Africa that build two applications to help stop the pandemic. The first application to solve one of the issues was… providing information for the population, because information is the key to prevent a pandemic to spread or kill.

slide-74
SLIDE 74

@misprintedtype

The process was… The population was informed about the number they could call to ask about ebola symptoms, to report someone sick or even dead. The call center tracked the calls with the application we’ve build, collected all the provided information from the caller and sent out a team, if needed.

slide-75
SLIDE 75

@misprintedtype

They added information through the application like the name, location and additional information. Also added the phone number of the caller, so they could call back for any further questions. Data analysis and filtering was really easy thanks to the application.

slide-76
SLIDE 76

@misprintedtype

rm -rf ~/

They fought with issues like unexpected and constant power loss. The generators jumped in after some time, but we could not afford to lose data. Just one case could have caused another outbreak and many deaths.

slide-77
SLIDE 77

@misprintedtype

first learning (data)

Our first learning here was…

slide-78
SLIDE 78

@misprintedtype

Decouple server && client

Decouple server and client, to serve the needs of a eventual contingency.

slide-79
SLIDE 79

@misprintedtype

build a task / message system

Build in a task and message system, that can act independently from the connectivity situation. For example… for data CouchDB, especially in combination with PouchDB proved their usability in the real world really, really well.

slide-80
SLIDE 80

@misprintedtype

CouchDB a NoSQL database that replicates, which is exactly what we want for sync. CouchDB comes with a suite of features, such as on-the-fly document transformation and real-time change notifications, we need for our message and task system, but also for a decoupled architecture.

slide-81
SLIDE 81

@misprintedtype

PouchDB is an open-source JavaScript database inspired by CouchDB that is designed to run well within the browser and store all your data locally while offline.

slide-82
SLIDE 82

@misprintedtype

It sync’s with CouchDB thanks to the CouchDB replication protocol, when the application is back online.

slide-83
SLIDE 83

@misprintedtype

save data documents locally

With PouchDB we actually have documents which are stored locally. So we won’t not flush the caches during by accident.

slide-84
SLIDE 84

@misprintedtype

prevent merge conflicts

One of the biggest issues with syncing data are merge conflicts. Because PouchDB and CouchDB speak the same protocol and sync automatically when we are back online and we do not need to take care of it.

slide-85
SLIDE 85

@misprintedtype

The second application we’ve build, was to actually track patient data in the field. After examining the infected patients, who had to stay in quarantine for 21 days. The team added the data to a general database through the application plus got lab results from several different entry points and very different file types.

slide-86
SLIDE 86

@misprintedtype

The data was imported, saved in a global database and synced all across all kind of devices. This all sounds super messy, right? What do you do with a mess? Well, I am a parent. So I am used to cleaning up a mess…

slide-87
SLIDE 87

@misprintedtype

second learning (schema)

Our second learning here was…

slide-88
SLIDE 88

@misprintedtype

define flexible data schema

We added an organization system. An interface to map the data in one defined schema. The schema was flexible enough to be extended, if needed… Thanks to the NoSQL database behind it.

slide-89
SLIDE 89

@misprintedtype

test data schema constantly

Data was imported automatically when it arrived (mostly per mail) or we added data on the fly. Constant automated testing and a high test coverage for the importer and the interface was a must.


slide-90
SLIDE 90

@misprintedtype

prevent merge conflicts

The schema and the testing helped us a lot here to prevent merge conflicts before the get go. CouchDB and PouchDB helped us to take care of the sync, merge and flexibility.

slide-91
SLIDE 91

@misprintedtype

prevent merge conflicts

Big bonus also? The schema also helped us with making filter and analyze the data, so visualizing it was really easy.

slide-92
SLIDE 92

@misprintedtype

10/2014 12/2015

We helped to curtail the pandemic, because of clean data structure and constant testing of the applications. If anyone tells you that those things don’t matter or you don’t have any time for those, you now know what to reply. Almost lunch… Guess, well picked theme for the next use case. Sorry in advance…

slide-93
SLIDE 93

@misprintedtype

the Pizza

  • > the Pizza
slide-94
SLIDE 94

@misprintedtype

We all love to order food, right? Did you ever check the localStorage when ordering? Just to see, if they save the cart items in it? A friend of mine did this once and went bit further out of curiosity. He was wondering if they are actually validating their checkout on the server.

slide-95
SLIDE 95

@misprintedtype

So he manipulated the checkout and subtracted one cent, send it out and waited. The pizza came. And no, there was no server side validation.

slide-96
SLIDE 96

@misprintedtype

Learnings (security)

What do we learn here?

slide-97
SLIDE 97

@misprintedtype

validate on server

In contrast to the limited possibilities of our use case before, this company could have validated the data on the server.

slide-98
SLIDE 98

@misprintedtype

validate on server

But this is sometimes not possible, especially when everything needs to work without any requests. Security is still a very new topic to offline first and not many tools are provided yet. And I’d be happy to chat especially about that topic after my talk.

slide-99
SLIDE 99

@misprintedtype

CORS <3

Although many of us seem to hate CORS sometimes, it provides already a great set of rules to make web applications more safe. But it does not solve the issues with the in-browser storage manipulation.

slide-100
SLIDE 100

@misprintedtype

encrypt local data

One way to go would be to encrypt your data. When you use PouchDB, you can add CryptoPouch, which encrypts your Pouch documents. Big downside here is, the document get’s encrypted, but not the ID. Which can lead back to security issues. But at least you can’t change the data anymore in the console.

slide-101
SLIDE 101

@misprintedtype

When you want to encrypt the data, you might want to log in. Which does not work without a request to the server, right? There is a way to use tokens in the client.

slide-102
SLIDE 102

@misprintedtype

JSON web tokens are an open industry standard method for representing claims securely between two parties, which is exactly what we want! It makes decoupled and secure sync and communication possible.

slide-103
SLIDE 103

@misprintedtype

BONUS 🤘 🚁 🎊

BONUS LEVEL!!! Because this is pretty much the most creative use case I’ve ever heard to solve the offline issue.

slide-104
SLIDE 104

@misprintedtype

the Rally

The Rally.

slide-105
SLIDE 105

@misprintedtype

https://en.wikipedia.org/wiki/Mongol_Rally#After_the_rally

Anyone of you heard about the Mongol Rally before? It’s an unconventional rally where people start from London or the Czech Republic and drive down to Mongolia. The main intention of this rally was a „donate your car“ program where every car that makes it to Mongolia, can be donated without import duties.

slide-106
SLIDE 106

@misprintedtype

http://www.minicong.com/lo-tec/

2009 a team from Spain took part in the rally. Nothing special at first glance… Well. The issue at the rally was, they had to cross a LOT of countries. With different receptions, different payment models for data volumes etc. So they needed a way to communicate with their loved ones, so they could say… „We are alive and well.“

slide-107
SLIDE 107

@misprintedtype

They built a system, that could encode an ASCII message in 8 bit binary code, ran the bits through 8 phones, that actually called just one number.

slide-108
SLIDE 108

@misprintedtype 1 2 3 4 5 6 7 8 1 1 1 1 1 1 1 1 1 1

To save money, they didn’t establish a full connection. It was mainly about letting it ring. The short ringing was a zero, the long ringing was a one. The other end, checked the numbers, which were set for order of bits and decoded the binary back in ASCII. Then it sends out message to loved ones. <3 Mind blowing, right? Yeah, people… :D

slide-109
SLIDE 109

@misprintedtype

Learnings

What do we learn here?

slide-110
SLIDE 110

@misprintedtype

Rethink how to use technology, by thinking about the issue. Not about the tools.

Read quote… Unidirectional communication. Very basic. They fixed it all already in the beginning by thinking about the real issue and not the solution first.

slide-111
SLIDE 111

@misprintedtype

You rock!

Okay, folks… Looks like our time is up. I hope, you had a great time and thank you for listening. If you have any questions, let’s talk. Otherwise please reach out via twitter or find me here somewhere. And remember…

slide-112
SLIDE 112

@misprintedtype

It’s not about frameworks… or design patterns or tools…

slide-113
SLIDE 113

@misprintedtype

… it’s about humans!

slide-114
SLIDE 114

@misprintedtype

we <3 you!

Thank you.

slide-115
SLIDE 115

@misprintedtype

And please remember to rate this session OR give feedback in person. Thank you!