Top Banner
/GrandParadePoland www.grandparade.co.uk React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever. Artur Grzybowski, Senior Development Lead at Grand Parade
21

React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Apr 16, 2017

Download

Internet

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

/GrandParadePolandwww.grandparade.co.uk

React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever.

Artur Grzybowski, Senior Development Lead at Grand Parade

Page 2: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Agenda

React-redux application

Server side rendering

Varnish-cache

Summary

/GrandParadePolandwww.grandparade.co.uk

Page 3: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

Quick review of React

Is just a view library

Is component based

Is based on state and props

Can return only single node

Components can be develop as a function or a class

/GrandParadePolandwww.grandparade.co.uk

Page 4: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

Quick review of Redux

Single source of truth - store

/GrandParadePolandwww.grandparade.co.uk

Page 5: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

Quick review of Redux

State is read-only

Changes are made by dispatching actions

/GrandParadePolandwww.grandparade.co.uk

Single source of truth - store

Page 6: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

Quick review of Redux

Actions are handled by reducers

/GrandParadePolandwww.grandparade.co.uk

Single source of truth - store

State is read-only

Changes are made by dispatching actions

Page 7: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

Quick review of Redux

Props are updated by connect function

/GrandParadePolandwww.grandparade.co.uk

Single source of truth - store

State is read-only

Changes are made by dispatching actions

Actions are handled by reducers

Page 8: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

Redux and async (fetch)

Return promise in action creator

Use redux-saga

Use redux-thunk

/GrandParadePolandwww.grandparade.co.uk

Page 9: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

React-redux application

/GrandParadePolandwww.grandparade.co.uk

Page 10: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

Why redux ? Isomorphic* app!

Single source of truth - store

/GrandParadePolandwww.grandparade.co.uk

Page 11: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

This doesn’t work!

/GrandParadePolandwww.grandparade.co.uk

Page 12: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

This doesn’t work!

componentDidMount vs componentWillMount

Once time rendering

We need wait for promises

/GrandParadePolandwww.grandparade.co.uk

Page 13: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

How to handle async then?

Expose fetchData function

Wait for all promises

/GrandParadePolandwww.grandparade.co.uk

Page 14: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

/GrandParadePolandwww.grandparade.co.uk

Page 15: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

Initial state

/GrandParadePolandwww.grandparade.co.uk

Page 16: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Server side rendering

/GrandParadePolandwww.grandparade.co.uk

Page 17: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Varnish-cache

What is varnish?

Caching proxy

Focused on high availability

Easy to configure

A lot of modules (VMODS)

/GrandParadePolandwww.grandparade.co.uk

Page 18: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Varnish-cache

/GrandParadePolandwww.grandparade.co.uk

Page 19: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Summary

Pros & cons

High availability services

High performance

Best user experience by getting page immediately

SEO support (and other crawlers)

/GrandParadePolandwww.grandparade.co.uk

Cache invalidation

Cache for logged user

There is still some additional code to do for isomorphic app

Page 20: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Summary

Links

https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree

https://www.smashingmagazine.com/2016/03/server-side-rendering-react-node-express/

https://www.codementor.io/reactjs/tutorial/redux-server-rendering-react-router-universal-web-app

https://reactjsnews.com/isomorphic-react-in-real-life

https://www.terlici.com/2015/03/18/fast-react-loading-server-rendering.html

https://blog.tableflip.io/server-side-rendering-with-react-and-redux/

/GrandParadePolandwww.grandparade.co.uk

Page 21: React-redux server side rendering enchanted with varnish-cache for the fastest web page delivering ever - Artur Grzybowski

Thank yougithub.com/FanFataL

/GrandParadePolandwww.grandparade.co.uk