Building for the personalisation spectrum
Phil Hawksworth, Netlify
Slide 2
Oh, hello Phil Hawksworth Developer Experience, Netlify
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
Some terminology ( sorry )
Slide 5
TERM 1
TERM 2
Rendering
Personalisation spectrum
Slide 6
Rendering
Slide 7
HTML / DOM
Slide 8
“…something something rendering on the server…” — Phil Hawksworth, 2013
Slide 9
“…ha ha ha do you just mean serving HTML?” — The person listening to Phil Hawksworth, 2013
Slide 10
Server
Client
Slide 11
Server
Client
Slide 12
Robustness
Slide 13
The rule of least power
https://unsplash.com/photos/iF5odYWB_nQ
Slide 14
Server
Client
Slide 15
Build
Server
Client
Slide 16
Build
Server
Edge
Client
Slide 17
Slide 18
“by thunder, there are a lot of ways to approach rendering!” — Phil Hawksworth, September 2023
Slide 19
The Personalisation Spectrum
Slide 20
We need the site to be personalised for the users — A requirement often expressed by my enterprise clients
Slide 21
What will the personalised content be, and does it currently exist? — A question I would always ask my enterprise clients
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
It’s not all or nothing
Slide 24
The Personalisation Spectrum
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
The rule of least power
https://unsplash.com/photos/iF5odYWB_nQ
Slide 27
Let’s return to
Rendering
Slide 28
A place for rendering
Slide 29
A time and a place for rendering
Slide 30
What / Where / When / How / Why
Slide 31
What / Where / When / How / Why
Slide 32
NAMING IS HARD
More terminology
Slide 33
NAMING IS HARD
Slide 34
RENDERING
SSG Static Site Generation Build
Server
Edge
Client
Slide 35
TRADITIONAL STACK
LOAD BALANCERS
WEB SERVERS
DATABASES
VARIOUS INCREASINGLY POPULAR PROVIDERS
ASSETS ON CDN
BUILD
AHEAD OF TIME
CODE & CONTENT
Slide 36
RENDERING
CSR Client side rendering Build
Server
Edge
Client
Slide 37
When… the assets have arrived
the user interacts
Slide 38
RENDERING
SSR Server side rendering Build
Server
Edge
Client
Slide 39
RENDERING
SSR Server side rendering Build
Server
Edge
Client
Slide 40
the-other-side
Build
Server
Edge
Client-side
Client
Slide 41
Build
Server
Server-side
Client-side
Edge
Client
Slide 42
Build
Server
Server-side?
Client-side
Edge
Client
Slide 43
not-Client-side
Build
Server
Edge
Client-side
Client
Slide 44
RENDERING
SSR Server side rendering Build
Server
Edge
Client
Slide 45
RENDERING
SSR Server side rendering Build
Server
Edge
Client
Slide 46
RENDERING
ESR Edge side rendering Build
Server
Edge
Client
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
“so which one is best, Phil?” — Some of you, possibly, September 2023
Slide 49
“It depends” — Phil Hawksworth, September 2023
Slide 50
“Yeah. Great. Thanks.” — Some of you, possibly, September 2023
Slide 51
“It depends on what?” — Some of you, hopefully, September 2023
Slide 52
“I’m glad you ask” — Me again, September 2023
Slide 53
The rule of least power
https://unsplash.com/photos/iF5odYWB_nQ
Slide 54
Best tool for digging a hole?
https://unsplash.com/photos/qG6QtyOaOGQ
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
Increments DPR / ODB / DSG / ISR / FFS
Slide 57
Increments DPR / ODB / DSG / ISR
Slide 58
Netlify + Gatsby
Gatlify Netsby Getslify Natsflibby NAMING IS HARD
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
TRADITIONAL STACK
LOAD BALANCERS
WEB SERVERS
DATABASES
VARIOUS INCREASINGLY POPULAR PROVIDERS SERVERLESS RUNTIME
ASSETS ON CDN
SERVERLESS RUNTIMES
BUILD
CODE & CONTENT
Slide 63
Increments DPR / ODB / DSG / ISR
Slide 64
RENDERING
ISR Incremental Static Regeneration
Slide 65
RENDERING
ISR Incremental Static Regeneration
SWR Stale While Revalidate
Slide 66
ODB
Render
View
User
Slide 67
ODB
Render
View
User
View
User
ISR
Render
Slide 68
“Which is better, ISR or DPR”? — Some of you, possibly, September 2023
Slide 69
“It depends”
Slide 70
Deciding demands questions
Slide 71
What are the requirements?
Slide 72
EXAMPLE
Social posts stash Applying different rendering techniques
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
JSON
Slide 75
/ Social index pages / Content pages Build
Assets
User JSON & Templates
Slide 76
www.hawksworx.com/notes/1/
Slide 77
Build duration 2 seconds
Slide 78
/ Post page view / Social index pages / Content pages Build
JSON & Templates
Assets
DPR (ODB)
User
Slide 79
www.hawksworx.com/note/mstdn/109913367394738833
Slide 80
/ Post page view / Social index pages / Content pages Build
JSON & Templates
Assets
DPR (ODB)
ESR / Search results page
User
Rendering sugar
Nuxt / Astro / Eleventy / Next and others
Slide 90
Applying this to personalisation
Slide 91
The Personalisation Spectrum Global
Localised
Segmented
Personalised
Slide 92
The Personalisation Spectrum Global
Localised
Segmented
Personalised
Pages generated at build time SSG
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 95
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 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
Based on system preferences or user input
Slide 100
Based on recent navigation You may also be interest in
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
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 104
Many techniques and options across the personalisation spectrum
Slide 105
FINALLY
Lessons Amid the confusion, what did we learn?
Slide 106
There is no one right way
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
Personalisation exists on a spectrum
Slide 109
Do work ahead of time if you can
Slide 110
You can mix and match rendering methods
Slide 111
Never choose an approach until you understand the requirements
Slide 112
Never choose an approach until you understand the constraints
Slide 113
Keep the rule of least power in mind
Slide 114
Not all of Phil’s tweets are pure gold
Slide 115
For more hawksworx.com netlify.com/blog/tutorials twitter.com/philhawksworth
Phil Hawksworth, Netlify
Slide 116
Thanks Grab me for questions (or to say hello)
Phil Hawksworth, Netlify
findthat.at/personalisation