SSR, CSR, SPA, PWA

Antons Sapriko
7 Sept 202028:30

Summary

TLDRThis script delves into the evolution of web development, contrasting traditional server-side rendering (SSR) with modern client-side rendering (CSR) and single-page applications (SPAs). It explains how SSR creates static web pages on the server, while CSR and SPAs leverage client devices for more dynamic, app-like interactions. The script highlights the benefits of reduced server load, faster data delivery, and enhanced user experience in modern web applications, particularly with the advent of technologies like service workers and GraphQL.

Takeaways

  • ๐ŸŒ Traditional web pages are server-dominated, with servers handling data storage, media, and rendering of HTML pages upon user requests.
  • ๐Ÿ“ฆ Server-Side Rendering (SSR) creates a static HTML page that is served to the user, which is efficient for certain types of websites but lacks personalization and control over caching.
  • ๐Ÿ“ฒ Client-Side Rendering (CSR) is more dynamic, with applications like those from app stores handling content rendering on the device, allowing for more interactivity and personalized user experiences.
  • ๐Ÿ› ๏ธ Magento, a traditional e-commerce platform, relies on a server to render pages, which can be resource-intensive and slow, especially when dealing with large amounts of data.
  • ๐Ÿ“ฑ The evolution of web technology has led to the development of Single Page Applications (SPAs), which load once and interact with APIs to fetch data, providing a more app-like experience on the web.
  • ๐Ÿ”ง Service workers act as a proxy server within the browser, managing caching, offline functionality, and data requests, making web applications more resilient and responsive.
  • ๐Ÿ“ˆ The shift from SSR to CSR and SPAs is driven by a desire for faster, more efficient, and personalized web experiences that can rival native apps.
  • ๐Ÿ“ˆ GraphQl, an API evolution, allows for granular data requests, reducing the amount of data transferred and improving the efficiency of data retrieval.
  • ๐Ÿ›‘ Browsers are evolving to support more application-like behaviors, with features like managed cache storage, non-SQL databases, and service workers, blurring the lines between web and app experiences.
  • ๐Ÿ”„ Modern JavaScript frameworks, such as React, facilitate the creation of SPAs and Progressive Web Apps (PWAs), enhancing user experience with fluid interactions and faster load times.
  • ๐Ÿ”„ The transition to SPAs and PWAs represents a significant shift in web development, moving from server resource consumption to device resource utilization for rendering and interactivity.

Q & A

  • What is the primary difference between Server-Side Rendering (SSR) and Client-Side Rendering (CSR)?

    -Server-Side Rendering involves the server creating a complete HTML page and sending it to the client, while Client-Side Rendering relies on the client's browser to construct the page using JavaScript after the initial HTML document is loaded.

  • What role does the server play in traditional web page serving?

    -In traditional web serving, the server runs the back-end application, stores data, and serves web pages to the user upon request. It may also handle caching to improve performance.

  • How does the use of CDN and caching affect the delivery of web pages?

    -CDN (Content Delivery Network) and caching help deliver web pages faster by storing copies of the content closer to the user's location, reducing latency and improving load times.

  • What is the significance of the 'view source' feature in a web browser?

    -The 'view source' feature allows users to see the HTML code of a web page, which is the result of the server's rendering process, and is useful for debugging and understanding how the page is constructed.

  • What are some limitations of traditional server-rendered web pages?

    -Traditional server-rendered pages are often static and lack interactivity. They also may not be optimized for individual users, as they serve a 'one size fits all' approach.

  • How does the architecture of a Magento-based e-commerce site typically work?

    -A Magento-based site typically uses a Linux server with a MySQL database, runs the Magento application on PHP, and utilizes services like Elasticsearch, Redis, and Varnish for caching and search functionalities.

  • What is the role of an API in the context of client-side rendered applications?

    -In client-side rendered applications, an API (Application Programming Interface) is used to request and receive data from the server, which the application then uses to dynamically render content on the client's device.

  • How do modern web applications differ from traditional web pages in terms of user interaction and experience?

    -Modern web applications, often built as Single Page Applications (SPAs), offer a more interactive and fluid user experience, similar to native apps, and can update parts of the UI without requiring a full page reload.

  • What is a Service Worker and how does it relate to web applications?

    -A Service Worker is a JavaScript-based proxy server that runs in the browser, managing caching, handling offline scenarios, and providing a smoother user experience by allowing for background data updates and push notifications.

  • What is the purpose of GraphQl in the context of modern web development?

    -GraphQl is a query language for APIs that allows clients to request exactly the data they need, reducing the amount of data transferred and improving efficiency in data fetching operations.

  • How do Progressive Web Apps (PWAs) leverage the capabilities of modern browsers to enhance user experience?

    -PWAs use modern web capabilities such as service workers, caching, and offline support to provide a more app-like experience, including fast loading, background updates, and the ability to work offline.

  • What is the main advantage of using Single Page Applications (SPAs) for e-commerce sites?

    -SPAs provide a faster and more seamless user experience by reducing the need to reload entire pages, allowing for on-the-fly updates and interactions, and leveraging the power of client-side devices for rendering.

Outlines

00:00

๐ŸŒ Understanding SSR and CSR in Web Development

This paragraph introduces the concepts of Server Side Rendering (SSR) and Client Side Rendering (CSR), explaining the traditional server-dominated web model where servers handle backend applications, data storage, and serve web pages to users. It discusses how servers create static web pages and the limitations of this approach, such as the lack of control over caching and the 'one size fits all' nature of static content. The speaker uses Magento as an example to illustrate the server's role in serving web pages and the evolution towards more interactive web applications.

05:02

๐Ÿ“ฒ Transition from Web Pages to Mobile Apps

The speaker contrasts traditional web pages with mobile applications, highlighting how apps are downloaded and then render content on the device using APIs to request data from servers. This approach allows for more interactivity and a better user experience, as apps can handle offline scenarios and leverage device hardware. The paragraph discusses the shift from static web pages served by servers to dynamic content rendered by apps, and how this has influenced the evolution of web technologies.

10:04

๐Ÿ› ๏ธ Browser Evolution and the Rise of Single Page Applications

This section delves into the advancements in browser technology, including managed cache storage, non-SQL databases, and service workers, which act as local proxy servers. The speaker discusses how these developments have allowed browsers to become more application-like environments. The paragraph also introduces the concept of Single Page Applications (SPAs), which bundle all possible layouts and styles into one package sent from the server, allowing for a more app-like experience on the web.

15:06

๐Ÿ”„ The Role of APIs and Service Workers in Modern Web Applications

The speaker explains how modern web applications use APIs, specifically GraphQL, to request specific data from servers, allowing for more efficient data retrieval. Service workers are highlighted as key components that manage data requests, check for cached data, and decide whether to fetch new data from the server or use local storage based on the user's online/offline status. This paragraph emphasizes the shift from server resource consumption to device resource consumption in rendering web content.

20:07

๐Ÿ›‘ The Impact of SPAs on User Experience and Performance

This paragraph discusses the benefits of Single Page Applications, such as improved speed due to smaller data requests and a more fluid, native app-like user experience. The speaker also touches on the ability to update UI elements without reloading the entire page and the use of placeholders to enhance the loading experience. The paragraph concludes by summarizing the transition from traditional web servers to data providers and the increased reliance on client-side rendering.

25:09

๐Ÿ”„ The Future of Web Applications: SPAs and Service Workers

The final paragraph wraps up the discussion by summarizing the evolution of web applications into SPAs and the role of service workers in managing data flow and offline capabilities. The speaker emphasizes the instant updates and improved performance of SPAs, comparing the initial load of an SPA to downloading an app from an app store. The paragraph concludes by inviting questions and reflecting on the comprehensive nature of the่ฎฒ่งฃ.

Mindmap

Keywords

๐Ÿ’กServer Side Rendering (SSR)

Server Side Rendering (SSR) refers to the process where the server generates the complete HTML content of a webpage and sends it to the client, which then displays it in the browser. In the video's context, SSR is traditionally how web pages were served, with the server handling the heavy lifting of data preparation, HTML generation, and style application, resulting in a static page sent to the user. The script mentions that SSR is 'big guys creating a static web page', illustrating the server's role in generating content before it is sent to the client.

๐Ÿ’กClient-Side Rendering (CSR)

Client-Side Rendering (CSR) is a technique where the initial HTML sent to the client is minimal, and the client's browser handles the rendering of the page by fetching necessary resources and executing JavaScript. The script contrasts CSR with SSR, explaining that with CSR, the server does not send a fully rendered page but rather pieces of data that the client's browser then uses to construct the page dynamically. This approach is more interactive and allows for a more 'app-like' user experience, as seen in modern web applications.

๐Ÿ’กAPI

API stands for Application Programming Interface, which is a set of rules and protocols for building software applications. In the script, the term API is used to describe how applications communicate with servers to request specific data, such as product information or user data. The script mentions the evolution of APIs, particularly GraphQL, which allows for more granular data requests, thus improving efficiency and reducing the amount of data transferred between the server and client.

๐Ÿ’กSingle Page Application (SPA)

A Single Page Application (SPA) is a web application that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from a server. The script discusses how SPAs, such as those built with React, have become more prevalent, allowing for a more app-like experience on the web. SPAs are delivered as a bundle of resources that include all the necessary UI components, which can then be populated with data fetched from the server.

๐Ÿ’กProgressive Web App (PWA)

Progressive Web Apps (PWAs) are web applications that are designed to deliver an app-like experience to users, with features such as offline support, push notifications, and the ability to be installed on the user's device. The script mentions PWAs in the context of modern web development, where the application is delivered to the client as a bundle, allowing for a seamless and fast user experience, similar to native apps but with the benefits of web technologies.

๐Ÿ’กService Worker

A Service Worker is a JavaScript file that acts as a proxy between the web application and the network, enabling features such as offline support and background sync. The script explains the role of Service Workers in managing caching, handling online and offline states, and providing a better user experience by allowing web applications to function more like native apps. It is a key technology that enables PWAs to work effectively.

๐Ÿ’กGraphQL

GraphQL is a query language for APIs and a runtime for executing those queries against your data. It allows clients to request exactly the data they need and nothing more. The script refers to GraphQL as an evolution of APIs, which is particularly useful for SPAs and PWAs, as it allows for more efficient data fetching and reduces the payload size, leading to faster and more responsive applications.

๐Ÿ’กCaching

Caching is the process of storing copies of data in a temporary storage area to improve performance. In the script, caching is discussed in the context of both traditional web servers and modern web applications. For SSR, caching can be used to serve static pages quickly. For SPAs and PWAs, caching is crucial for offline support and reducing the need to re-fetch data, as managed by Service Workers.

๐Ÿ’กE-commerce

E-commerce refers to the buying and selling of goods and services, or the transmitting of funds or data, over an electronic network, primarily the internet. The script uses e-commerce as an example to illustrate the differences between SSR and CSR, as well as the benefits of SPAs and PWAs in providing a seamless shopping experience. It discusses how modern e-commerce platforms can leverage these technologies to improve performance and user experience.

๐Ÿ’กMagento

Magento is an open-source e-commerce platform written in PHP. The script mentions Magento in the context of traditional e-commerce setups, where it is used to run the back-end of an online store. It also discusses how Magento can be integrated with modern web technologies like SPAs and PWAs to provide a more dynamic and efficient shopping experience.

Highlights

SSR (Server Side Rendering) and CSR (Client-Side Rendering) concepts are unpacked to clarify their meanings and differences.

Traditional web is server-dominated, with servers responsible for running back-end applications and serving web pages.

SSR involves servers creating static web pages, which can be limited in terms of caching and content control.

Magento, a traditional e-commerce platform, uses a server-centric approach with technologies like PHP, MySQL, and caching services.

Mobile applications, in contrast, download content once and render pages on the device, reducing the need for server resources with each request.

APIs play a crucial role in mobile apps, fetching data in a granular and efficient manner.

The evolution of web applications is moving towards a model more akin to mobile apps, with increased interactivity and reduced server load.

Single Page Applications (SPAs) and Progressive Web Apps (PWAs) represent a shift towards client-side rendering and interactivity.

Service workers act as local proxy servers, managing caching and offline capabilities within the browser.

Modern JavaScript frameworks, such as React, facilitate the creation of SPAs and PWAs for a more app-like web experience.

Browsers are evolving to support applications more effectively, with features like managed cache storage and service workers.

The transition from SSR to CSR involves a shift from bulky data transfers to more granular, efficient data requests.

E-commerce platforms like Magento are adapting to this shift by becoming API servers, focusing on data provision rather than page rendering.

User experience in SPAs is enhanced through fluid interactions and the ability to update UI elements without full page reloads.

The first load of a SPA provides the entire application structure, with subsequent requests only needing data updates.

Service workers allow for offline functionality and background updates, improving the reliability and freshness of content.

The presentation concludes by emphasizing the practical benefits of the shift to CSR in terms of speed and user experience.

Transcripts

play00:01

hello guys i will try to shed

play00:04

a bit more light on ssr

play00:07

and cstr because the definition

play00:11

itself of server side rendering and

play00:13

client-side rendering

play00:15

do not usually unbox the whole meaning

play00:18

of these concepts so

play00:22

let's look first as a web as we used to

play00:26

know it

play00:28

i think it is heavily server dominated

play00:32

so there is a server it runs back-end

play00:35

application

play00:36

it stores data it may have media

play00:40

we might store it at cdn at the edge

play00:43

and then server is actually serving

play00:46

web pages once

play00:49

a user is opening browser

play00:53

requesting a particular url for example

play00:56

list of products server is

play01:00

either serving this web page from cache

play01:03

or would request an application

play01:08

to prepare data to request the data

play01:12

wrap it into style sheets

play01:15

and render on a server

play01:19

so rendering is

play01:21

[Music]

play01:23

to say creating a

play01:27

response in form of html

play01:30

html page the one you see in view source

play01:34

when you open a web page

play01:38

view view source or right click on the

play01:41

page and then choose view source and you

play01:43

see those

play01:43

headers you see all the html tag text

play01:47

you see

play01:49

css classes there so servers where

play01:53

big guys are still big guys creating

play01:58

a static web page generally

play02:02

that we are consuming

play02:07

the brothers do have cash but

play02:11

it is one size fits all so we can't

play02:14

really control it it is good for

play02:16

e-commerce stores for blogs for social

play02:19

media for

play02:21

anything so we need to change

play02:24

names of the files to get them updated

play02:28

or we cannot really

play02:30

set any time to live or check whether we

play02:32

have certain caching up

play02:37

um to put it in a context

play02:41

and i guess this is this one is pretty

play02:44

clear so

play02:45

if we talk specifically about our case

play02:48

of magentos and

play02:50

we have a tradition like linux server

play02:53

we run mysql database

play02:57

back-end uh magento application

play03:00

uh is run on php and it has certain

play03:04

services like elasticsearch

play03:06

redis and varnish

play03:09

for caching and for search or for

play03:12

storing certain collections like they

play03:14

used to be stored in flat tables not

play03:16

starting classic search so

play03:18

there is a whole life going on on the

play03:21

server

play03:22

so server does a lot of things and we as

play03:25

a user we get a web page

play03:28

pretty much static thing as it is

play03:32

as you can see by name it's a page

play03:38

and browser i used to display it okay

play03:41

we click on some hyperlink and then we

play03:43

send another request and server

play03:46

link is computing certain things

play03:50

putting them into html applying styles

play03:54

and sending us pretty big piece of data

play03:57

over the internet we are sending a small

play03:58

piece small request

play04:00

for url and getting back pretty large

play04:02

html

play04:03

can be several megabytes

play04:06

even without images so in

play04:09

to put it in a context let's

play04:13

compare it and contrast it a little bit

play04:16

with applications

play04:20

that are being downloaded from the apple

play04:22

play stores

play04:24

so not look into why this really

play04:26

originated where there are technological

play04:28

or business

play04:29

reasons for it but

play04:32

we know that we have a device

play04:36

and we have certain application stores

play04:38

there and available

play04:40

home screen with one click

play04:45

do applications if we talk about

play04:47

e-commerce

play04:48

need back-end definitely yes

play04:52

it's not a say single player games that

play04:57

you can just play without an internet

play05:01

connection so

play05:03

you need to download images download

play05:06

updated prices

play05:07

in stock out of stocks and certain

play05:10

requests like

play05:10

adding to cart so you need server

play05:15

but um as we see

play05:19

here we we don't have web pages anymore

play05:24

instead

play05:26

[Music]

play05:28

the pages

play05:31

of the content is being

play05:34

rendered by the application

play05:38

so the application that we initially

play05:40

like spent up to the

play05:42

30 seconds we mean it downloading

play05:45

it from the app store

play05:48

not even our server

play05:52

contains actually all the web pages

play05:56

we might want to show to the customer

play05:59

but

play06:02

without data so that's why here is a new

play06:04

actor of

play06:06

api

play06:10

so we download the application

play06:12

application understands okay i'm here

play06:15

we had the home page i have no idea what

play06:18

i need to display so okay i have certain

play06:21

components

play06:22

okay the slider so let me ask slider

play06:25

from a server through api

play06:27

let me ask uh six best sellers and

play06:31

let me ask quite some banner block okay

play06:34

and this information is delivered as

play06:38

pieces of data not a web page so we are

play06:41

not

play06:42

deliver like sending to the application

play06:45

i mean unless it's just a webview but we

play06:47

talk about

play06:48

native apps we are sending certain

play06:51

pieces of data like a json uh with uh

play06:55

say urls of sliders where we can get

play06:59

images

play07:00

and clickable elements and then

play07:04

some urls to proceed further

play07:08

applications do have controlled storage

play07:11

it's limited but

play07:15

you can use it while offline for example

play07:19

and it has access to hardware

play07:23

and it feels differently because it's

play07:26

different rendering technologies and

play07:29

browsers it is used to

play07:32

display static pages

play07:36

so it feels differently you can interact

play07:39

with certain pieces of the screen

play07:42

and it's generally faster because

play07:45

instead of sending a complete

play07:47

web page every time you request

play07:51

a new page request new page

play07:54

server is preparing a new page and

play07:56

sending it

play07:58

you're requesting just a granular

play08:02

update for

play08:06

for a particular page or you're

play08:08

requesting

play08:09

a relatively smaller piece of data to be

play08:13

downloaded to your device

play08:16

because you already have all the styles

play08:19

it's user interface as such already have

play08:22

it downloaded

play08:27

um so how

play08:31

does it relate to our conversation about

play08:34

web because we seem to have

play08:37

kind of web here and apps here

play08:41

well it has relation because what is

play08:45

in my opinion happening right now is

play08:47

that

play08:50

websites that are

play08:54

not serving static content

play08:57

but have certain interaction with the

play08:59

user even if this interaction is just

play09:02

adding stuff to a cart or customizing

play09:04

your products or filtering stuff or

play09:08

maybe choosing some

play09:11

personalization options or even if it

play09:17

has certain access to features like

play09:19

apple pages they

play09:21

are becoming more like apps

play09:24

what does it mean so let's let's

play09:27

move the image further

play09:35

and here we have a kind of

play09:39

the next box they still have server and

play09:42

have device

play09:44

but uh for the next

play09:48

game iteration

play09:52

of what we are developing can interrupt

play09:54

to happen

play09:55

there need to occur certain

play09:58

technological advances

play10:01

and such did occur

play10:04

specifically on the device in the

play10:07

browser

play10:09

now we have managed cache storage

play10:12

and even non-sql key value index db

play10:17

furthermore browsers have a

play10:21

dedicated new entity you can register

play10:24

and manage

play10:25

within them called service worker

play10:31

written in javascript you can think

play10:32

about it as a kind of proxy server we'll

play10:35

talk later why you might need a proxy

play10:37

server locally

play10:42

and all of these kind of

play10:46

hints that we

play10:51

we want to do or browsers

play10:54

are just responding to a trend that we

play10:57

want to do more in browser or browser

play11:01

say

play11:01

browsers want people and developers to

play11:04

start doing

play11:05

more in browsers than on servers

play11:10

or that browsers want to be more like

play11:14

an environment to run applications

play11:16

rather than

play11:17

serve pages so browsers

play11:22

want to evolve

play11:25

what happens on server side

play11:29

well web pages are

play11:33

not something that is being like

play11:35

advancing anymore

play11:37

apis are advancing specifically

play11:41

we'll look into what's happening there

play11:43

it's in next

play11:46

slide

play11:50

but as we have discussed

play11:54

in the previous setup that web pages

play11:57

have migrated into

play11:59

applications that was downloaded from

play12:01

the

play12:02

app store in

play12:05

our next drawing

play12:08

web pages are migrating

play12:12

into something we call when we call it's

play12:15

called

play12:15

that is called sp single page

play12:19

application so

play12:23

its purpose is similar to an application

play12:26

that

play12:26

is distributed from the app store to

play12:29

[Music]

play12:30

to represent or well yeah to to be

play12:33

to represent the whole different array

play12:37

of

play12:38

pages we want to serve so we've talked

play12:41

about ecommerce and it's

play12:43

it's a layout and styles for home page

play12:48

listing page filter search

play12:51

product detail page content page

play12:53

customer account

play12:55

card checkout wishlist

play12:58

reviews brand pages store locator

play13:02

anything we would want to serve

play13:07

uh within the

play13:11

house is the goals of the project

play13:14

so we are not

play13:18

serving it as web pages

play13:22

anymore instead we

play13:27

we pack all of the possible layouts

play13:31

in a single page application and

play13:34

send it right away from our server in

play13:37

bundles

play13:41

we don't have any intermediary like a

play13:43

play store

play13:44

here and this advancement has happened

play13:47

neither on server nor on device

play13:49

it's uh it's a javascript framework

play13:53

javascript used to be downloaded long

play13:55

time ago on browser

play13:57

but with the emergence of

play14:01

specific react we are working with

play14:05

single page applications and a subset of

play14:08

them called progressive web apps

play14:11

has become possible

play14:15

and in our drawing that's the first

play14:18

thing that user gets into their browser

play14:23

progressive web manifest and application

play14:27

itself and as the word suggests

play14:31

suggests

play14:36

the pages have been static application

play14:39

is actually

play14:43

doing something so in our case it is

play14:48

requesting

play14:51

and receiving data probably we can move

play14:56

here

play15:00

so once a single page application is

play15:02

downloaded to our device

play15:05

just like a usual application from a

play15:08

store it starts

play15:09

starts requesting data and there is an

play15:12

api evolution in form of graphquails

play15:15

that

play15:16

is sending you exactly the data you are

play15:17

requesting a granular

play15:19

access to data with just the price of a

play15:22

product it

play15:22

gives you just price not an entire

play15:26

product object that you need to

play15:29

parse and extract necessary data later

play15:33

so the single page application written

play15:36

react is requesting

play15:38

data and whatever it does

play15:42

it does through service workers so it

play15:44

requests data through service worker

play15:47

why the service worker is checking

play15:49

whether this data has been already

play15:50

requested and is available

play15:52

in cash storage so there is

play15:55

decision making locally on a client side

play15:58

should i request data am i

play16:01

online am i offline uh

play16:04

well if i'm on offline i'm still working

play16:08

but i'm showing just certain

play16:11

placeholders instead of the data i

play16:13

cannot retrieve from from the

play16:14

from the server and i'm showing the

play16:17

actual data i

play16:19

was retrieving and i have saved locally

play16:22

so i can retrieve it and display

play16:26

for the user

play16:30

to recap

play16:34

we still have servers we still have

play16:37

devices

play16:40

we still use browsers

play16:43

and we still have good old mysqls

play16:47

php magento and media

play16:52

and then the similarity ends

play16:57

servers are not anymore requested to

play17:02

spend resources on

play17:05

rendering pages and then sending a

play17:08

bulky piece over

play17:11

to the user device instead now servers

play17:16

are requested to provide

play17:21

well a date object that will be

play17:26

passed through service worker possibly

play17:30

parts of its word in local cache and

play17:33

then this data will be

play17:35

injected into single page application

play17:37

layout

play17:40

and rendered

play17:44

locally on the client side in the

play17:46

browser

play17:48

so instead of consuming server resources

play17:50

we are consuming

play17:51

device resources and

play17:55

naturally if we have a very very old

play17:58

device it might get a bit laggy

play18:02

but um

play18:05

this is a theoretical problem because

play18:08

the current state of

play18:10

device will ability uh

play18:14

is uh he is completing

play18:19

very well the goal of rendering what say

play18:22

we are working with

play18:23

uh e-commerce on magento and scandi pwa

play18:29

so we have servers uh now they are

play18:32

providers

play18:33

not of pages that we can consume right

play18:35

away they're providers of data so

play18:38

they are how to say we are api

play18:41

consumers and they are well api servers

play18:49

devices are now your

play18:52

rendering engine so they already have

play18:55

all the user interface of the

play18:57

application

play18:58

the commerce store you want to use

play19:03

and they're requesting a data from

play19:05

server

play19:06

they're sending pretty short requests

play19:08

for data and they are getting something

play19:10

that can be up to like

play19:12

10 times smaller in size

play19:15

than they used to request before so

play19:19

here is a gain and speed

play19:23

and single page applications are written

play19:26

in more than languages like modern

play19:29

javascript framework reacting our

play19:31

purpose

play19:32

in our case so

play19:36

the user experience of interacting with

play19:40

the application in this case or just

play19:43

with

play19:43

information on the screen for the user

play19:46

they don't care if the page

play19:47

is application is different is more

play19:50

fluid

play19:52

you can update your page module like

play19:57

in in modules

play19:59

[Music]

play20:03

you can make

play20:07

certain ui elements already available

play20:10

without

play20:11

waiting for the entire page to load

play20:14

you can

play20:18

kind of elevate loader

play20:21

to another level by issuing placeholders

play20:23

of the

play20:25

kind of showing a content structure

play20:27

previewing

play20:28

what a user will get

play20:31

so we get the advantage of speed

play20:34

because

play20:38

the pieces of data we are sending are

play20:41

much

play20:42

smaller because we are requesting

play20:45

not the entire page by just data because

play20:48

the pieces of the page that is user

play20:50

interface we already got with the first

play20:52

load

play20:54

and user experience is more like native

play20:57

apps

play20:59

because we use modern javascript

play21:02

frameworks such as react for single page

play21:06

application

play21:12

i will tell us a bonus what a single

play21:14

page application

play21:16

but just to recap because i

play21:20

feel that it it's a bit similar to

play21:22

explaining

play21:23

bitcoin or blockchain to the people it's

play21:26

really something new but

play21:28

we need to find some common ground

play21:31

and then kind of harmonize the common

play21:35

knowledge with some new ways of using

play21:38

it so we used to have servers we used to

play21:42

have back and send data and media

play21:44

there we used to had devices and

play21:46

browsers and users were requesting

play21:48

certain urls

play21:50

and servers were happy to serve them

play21:52

either from

play21:53

cached version of this page or request

play21:58

this page from the application

play21:59

application request data from the

play22:01

database

play22:02

and then they would merge this data with

play22:05

styles with html

play22:07

and send this pretty large piece of

play22:10

data over to the browser and browsers

play22:12

were happy to display

play22:19

it works very well

play22:22

but merchants love every way how to make

play22:25

it faster

play22:26

quite obvious they need to decrease the

play22:30

amount of

play22:31

the stuff they're sending from server

play22:34

and it's quite obvious they're sending

play22:36

all the time the same stuff again and

play22:38

again

play22:42

and well there's there is an application

play22:45

that's why they here they were

play22:47

presenting they are presenting a clear

play22:50

contrasting example of how it it is it

play22:53

has been possible to achieve it

play22:55

to pack all your styles into the

play22:57

application

play22:59

uh manage storage so you don't need to

play23:02

download stuff

play23:03

twice or several times you can use

play23:06

something

play23:07

offline and use servers

play23:10

as as a way to access

play23:14

database say in a certain

play23:20

structured way through api

play23:23

so servers were not anymore serving

play23:26

something that was directly consumable

play23:29

by the user instead they were serving

play23:31

only data in certain like comma separate

play23:34

or

play23:34

json format that was consumed by the

play23:38

application

play23:40

application was figuring out how to

play23:42

displace

play23:43

data for the user and whether to store

play23:46

this data in local storage or not

play23:49

but much more power was on the side

play23:52

of device and application

play23:56

and then browsers

play24:00

decided to evolve the tell well

play24:04

why not we browsers now introduce

play24:07

something that can make

play24:10

us play stores and app stores

play24:15

why don't we deliver applications rather

play24:18

than pages because we can

play24:22

and not only browsers can

play24:30

also the pages have evolved

play24:33

into a single page applications so

play24:36

now all these styles that were

play24:39

previously present on the server now we

play24:42

can package in bundle

play24:44

bundles and send over to the device with

play24:46

the first load

play24:48

first load and you got your entire

play24:52

magento store but without all data just

play24:55

with all the designs

play24:57

you got it on your device

play25:01

it's there it's empty

play25:06

when i talk about empty store i tell

play25:08

okay

play25:09

when you download for the first time you

play25:11

so farfetch

play25:13

how many products are there like

play25:15

everybody like what you don't want to

play25:16

store right

play25:17

okay usually talk to students

play25:20

okay when you download tinder for the

play25:22

first time how many profiles

play25:26

and then zero like okay so it's just

play25:30

empty application so the same is the

play25:32

same things can dpw is an

play25:34

empty commerce store but just with nice

play25:38

styles

play25:39

fonts language translations and it

play25:42

understands

play25:43

what it needs to ask servers need

play25:46

request to server in each particular

play25:48

moment so when we open for the first

play25:50

time for example it would request the

play25:52

data necessary for the home page

play25:55

and it would do it through its own proxy

play25:57

service worker

play25:59

why service worker manages online and

play26:02

offline stay

play26:03

just like in an application so it would

play26:06

be able to serve content log like from

play26:10

local storage while offline or even

play26:13

receive orders save it

play26:16

locally and then send it over

play26:19

to the server whenever it understands

play26:21

okay i am back online

play26:23

it also displays offline message uh

play26:26

sorry i flow offline uh it

play26:32

well it can also update itself actually

play26:35

so whenever service worker understands

play26:37

that

play26:38

it's it's something managed by the

play26:40

browser itself itself service worker

play26:44

it's a browser entity uh

play26:48

browser will would request a new version

play26:51

of service worker

play26:52

from the server in our case of scan dpw

play26:56

we would invalidate

play26:57

all the local cache that

play27:00

has been accumulated so far because

play27:03

there can be some

play27:05

inconsistencies in with a new

play27:08

version and all data formats so we

play27:11

rather

play27:11

play it safe and on activate we flush

play27:15

all the location

play27:18

um so now with the first load

play27:21

we get the application and it's again

play27:24

it's

play27:25

application so it's actually it's doing

play27:26

something it's requesting that it is

play27:29

getting data is

play27:30

checking whether this data has been

play27:32

updated so it's updates local storage

play27:35

and it's injecting the data into the

play27:38

layouts into react templates components

play27:42

applying style sheets and rendering it

play27:45

for you

play27:46

on your device just like an application

play27:51

but each time you open the url

play27:54

you get a new one and generally you need

play27:58

you need not to wait more than one

play28:00

maximum two seconds to get it

play28:03

unlike much longer

play28:07

downloads from the play stores and

play28:10

updates are instant

play28:15

i think i rather stop here i should

play28:19

be again five minutes but it's close to

play28:21

half an hour

play28:24

i hope it has been it was useful

play28:27

questions welcome

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Web DevelopmentSSRCSRSPAPWAAPIsCachingMagentoReactService WorkersMobile Apps