Building for the personalisation spectrum

A presentation at WaysConf in September 2023 in Kraków, Poland by Phil Hawksworth

Slide 1

Slide 1

Building for the personalisation spectrum Phil Hawksworth, Netlify

Slide 2

Slide 2

Oh, hello Phil Hawksworth Developer Experience, Netlify

Slide 3

Slide 3

n I d e k n i L s d a h re T Oh, hello Tw i t te r G i tH u @ PhilHawksworth Developer Experience, Netlify Bl ueS k y n o d o M as t b

Slide 4

Slide 4

Some terminology ( sorry )

Slide 5

Slide 5

TERM 1 TERM 2 Rendering Personalisation spectrum

Slide 6

Slide 6

Rendering

Slide 7

Slide 7

HTML / DOM

Slide 8

Slide 8

“…something something rendering on the server…” — Phil Hawksworth, 2013

Slide 9

Slide 9

“…ha ha ha do you just mean serving HTML?” — The person listening to Phil Hawksworth, 2013

Slide 10

Slide 10

Server Client

Slide 11

Slide 11

Server Client

Slide 12

Slide 12

Robustness

Slide 13

Slide 13

The rule of least power https://unsplash.com/photos/iF5odYWB_nQ

Slide 14

Slide 14

Server Client

Slide 15

Slide 15

Build Server Client

Slide 16

Slide 16

Build Server Edge Client

Slide 17

Slide 17

Slide 18

Slide 18

“by thunder, there are a lot of ways to approach rendering!” — Phil Hawksworth, September 2023

Slide 19

Slide 19

The Personalisation Spectrum

Slide 20

Slide 20

We need the site to be personalised for the users — A requirement often expressed by my enterprise clients

Slide 21

Slide 21

What will the personalised content be, and does it currently exist? — A question I would always ask my enterprise clients

Slide 22

Slide 22

Technology Data Content Does the platform provide personalisation? Do we know who the user is, and what to show to them? Do we have all the content and ways to manage it?

Slide 23

Slide 23

It’s not all or nothing

Slide 24

Slide 24

The Personalisation Spectrum

Slide 25

Slide 25

The Personalisation Spectrum Not personalised Highly personalised Global Localised Segmented Personalised Universal content, served to all Different content served to visitors from specific locations or regions Batches of content served to identified cohorts of users Content intended for a specific individual, based on what we know about them

Slide 26

Slide 26

The rule of least power https://unsplash.com/photos/iF5odYWB_nQ

Slide 27

Slide 27

Let’s return to Rendering

Slide 28

Slide 28

A place for rendering

Slide 29

Slide 29

A time and a place for rendering

Slide 30

Slide 30

What / Where / When / How / Why

Slide 31

Slide 31

What / Where / When / How / Why

Slide 32

Slide 32

NAMING IS HARD More terminology

Slide 33

Slide 33

NAMING IS HARD

Slide 34

Slide 34

RENDERING SSG Static Site Generation Build Server Edge Client

Slide 35

Slide 35

TRADITIONAL STACK LOAD BALANCERS WEB SERVERS DATABASES VARIOUS INCREASINGLY POPULAR PROVIDERS ASSETS ON CDN BUILD AHEAD OF TIME CODE & CONTENT

Slide 36

Slide 36

RENDERING CSR Client side rendering Build Server Edge Client

Slide 37

Slide 37

When… the assets have arrived the user interacts

Slide 38

Slide 38

RENDERING SSR Server side rendering Build Server Edge Client

Slide 39

Slide 39

RENDERING SSR Server side rendering Build Server Edge Client

Slide 40

Slide 40

the-other-side Build Server Edge Client-side Client

Slide 41

Slide 41

Build Server Server-side Client-side Edge Client

Slide 42

Slide 42

Build Server Server-side? Client-side Edge Client

Slide 43

Slide 43

not-Client-side Build Server Edge Client-side Client

Slide 44

Slide 44

RENDERING SSR Server side rendering Build Server Edge Client

Slide 45

Slide 45

RENDERING SSR Server side rendering Build Server Edge Client

Slide 46

Slide 46

RENDERING ESR Edge side rendering Build Server Edge Client

Slide 47

Slide 47

TRADITIONAL STACK LOAD BALANCERS WEB SERVERS DATABASES VARIOUS INCREASINGLY POPULAR PROVIDERS SERVERLESS RUNTIME ASSETS ON CDN SERVERLESS RUNTIMES BUILD CODE & CONTENT

Slide 48

Slide 48

“so which one is best, Phil?” — Some of you, possibly, September 2023

Slide 49

Slide 49

“It depends” — Phil Hawksworth, September 2023

Slide 50

Slide 50

“Yeah. Great. Thanks.” — Some of you, possibly, September 2023

Slide 51

Slide 51

“It depends on what?” — Some of you, hopefully, September 2023

Slide 52

Slide 52

“I’m glad you ask” — Me again, September 2023

Slide 53

Slide 53

The rule of least power https://unsplash.com/photos/iF5odYWB_nQ

Slide 54

Slide 54

Best tool for digging a hole? https://unsplash.com/photos/qG6QtyOaOGQ

Slide 55

Slide 55

Serverside, doesn’t have to mean Serverful. If I can do things in advance, I will. If I can’t, but can do things serverless, I will. If I can’t, but can add a server, I will.

Slide 56

Slide 56

Increments DPR / ODB / DSG / ISR / FFS

Slide 57

Slide 57

Increments DPR / ODB / DSG / ISR

Slide 58

Slide 58

Netlify + Gatsby Gatlify Netsby Getslify Natsflibby NAMING IS HARD

Slide 59

Slide 59

Increments DPR / ODB / DSG / ISR

Slide 60

Slide 60

RENDERING DPR Distributed Persistent Rendering RENDERING RENDERING ODB DSG On-demand Builders Deferred Static Generation

Slide 61

Slide 61

DGIITBWUTFTIRTGIAATWWBE NAMING IS HARD Don’t generate it in the build. Wait until the first time it’s requested, then generate it and add it to what was built earlier.

Slide 62

Slide 62

TRADITIONAL STACK LOAD BALANCERS WEB SERVERS DATABASES VARIOUS INCREASINGLY POPULAR PROVIDERS SERVERLESS RUNTIME ASSETS ON CDN SERVERLESS RUNTIMES BUILD CODE & CONTENT

Slide 63

Slide 63

Increments DPR / ODB / DSG / ISR

Slide 64

Slide 64

RENDERING ISR Incremental Static Regeneration

Slide 65

Slide 65

RENDERING ISR Incremental Static Regeneration SWR Stale While Revalidate

Slide 66

Slide 66

ODB Render View User

Slide 67

Slide 67

ODB Render View User View User ISR Render

Slide 68

Slide 68

“Which is better, ISR or DPR”? — Some of you, possibly, September 2023

Slide 69

Slide 69

“It depends”

Slide 70

Slide 70

Deciding demands questions

Slide 71

Slide 71

What are the requirements?

Slide 72

Slide 72

EXAMPLE Social posts stash Applying different rendering techniques

Slide 73

Slide 73

Some requirements A URL for each of the 24,000 tweets Index pages listing each tweet with its URL Ability to search the tweets Retain a reasonable build time Avoid client-side rendering if possible A logical model that fits in my head SSG DPR ESR

Slide 74

Slide 74

JSON

Slide 75

Slide 75

/ Social index pages / Content pages Build Assets User JSON & Templates

Slide 76

Slide 76

www.hawksworx.com/notes/1/

Slide 77

Slide 77

Build duration 2 seconds

Slide 78

Slide 78

/ Post page view / Social index pages / Content pages Build JSON & Templates Assets DPR (ODB) User

Slide 79

Slide 79

www.hawksworx.com/note/mstdn/109913367394738833

Slide 80

Slide 80

/ Post page view / Social index pages / Content pages Build JSON & Templates Assets DPR (ODB) ESR / Search results page User

Slide 81

Slide 81

www.hawksworx.com/notes/search/?str=palo+alto www.hawksworx.com/notes/search/?str=render

Slide 82

Slide 82

Slide 83

Slide 83

Slide 84

Slide 84

Slide 85

Slide 85

Slide 86

Slide 86

Abstraction

Slide 87

Slide 87

At build time JSON At request time

Slide 88

Slide 88

At build time Data source At request time

Slide 89

Slide 89

Rendering sugar Nuxt / Astro / Eleventy / Next and others

Slide 90

Slide 90

Applying this to personalisation

Slide 91

Slide 91

The Personalisation Spectrum Global Localised Segmented Personalised

Slide 92

Slide 92

The Personalisation Spectrum Global Localised Segmented Personalised Pages generated at build time SSG

Slide 93

Slide 93

The Personalisation Spectrum Global Localised Segmented Personalised Global and localised pages generated at build time. + Users directed to appropriate URLs SSG

Slide 94

Slide 94

Slide 95

Slide 95

Slide 96

Slide 96

The Personalisation Spectrum Global Localised Segmented Personalised Global and localised pages generated at build time. + Users directed to appropriate URLs + Cookies and Edge Functions enrich views for returning users SSG ESR

Slide 97

Slide 97

Slide 98

Slide 98

The Personalisation Spectrum Global Localised Segmented Personalised Global and localised pages generated at build time. + Users directed to appropriate URLs + Cookies and Edge Functions enrich views for user preference, behaviours SSG ESR

Slide 99

Slide 99

Based on system preferences or user input

Slide 100

Slide 100

Based on recent navigation You may also be interest in

Slide 101

Slide 101

The Personalisation Spectrum Global Localised Segmented Personalised Global and localised pages generated at build time. + Users directed to appropriate URLs + Cookies and Edge Functions enrich views for user preference, behaviours SSG ESR

Slide 102

Slide 102

The Personalisation Spectrum Global Localised Segmented Personalised Global and localised pages generated at build time. + Users directed to appropriate URLs + Cookies and Edge Functions enrich views for user preference, behaviours + Personal content added via authenticated APIs SSG ESR CSR

Slide 103

Slide 103

Slide 104

Slide 104

Many techniques and options across the personalisation spectrum

Slide 105

Slide 105

FINALLY Lessons Amid the confusion, what did we learn?

Slide 106

Slide 106

There is no one right way

Slide 107

Slide 107

TRADITIONAL STACK LOAD BALANCERS WEB SERVERS DATABASES VARIOUS INCREASINGLY POPULAR PROVIDERS SERVERLESS RUNTIME ASSETS ON CDN SERVERLESS RUNTIMES BUILD CODE & CONTENT

Slide 108

Slide 108

Personalisation exists on a spectrum

Slide 109

Slide 109

Do work ahead of time if you can

Slide 110

Slide 110

You can mix and match rendering methods

Slide 111

Slide 111

Never choose an approach until you understand the requirements

Slide 112

Slide 112

Never choose an approach until you understand the constraints

Slide 113

Slide 113

Keep the rule of least power in mind

Slide 114

Slide 114

Not all of Phil’s tweets are pure gold

Slide 115

Slide 115

For more hawksworx.com netlify.com/blog/tutorials twitter.com/philhawksworth Phil Hawksworth, Netlify

Slide 116

Slide 116

Thanks Grab me for questions (or to say hello) Phil Hawksworth, Netlify findthat.at/personalisation