Skip to content

hasangenc0/worker-side-rendering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Load pages 2x times faster

About this repository

This app built for showing how to cut html payload with service workers. (insipired by this article)

Idea

Main idea is using service workers to caching only templates of the parts of the page (not contains data) and serving just content to feed those templates when browser sends request to server.

How

  • Server Configuration

    • / and /trendyol routes serve full html with content.
    • If this routes have ?contentOnly=true parameter, server just sends the content of that page.
    • Serve templates.
    • /template serves template of the / page.
    • /trendyol/partials/:partial serves multiple templates of the /trendyol page.
  • Service Worker Configuration

    • After installation of service worker cache the templates of that page.
    • When browser sends request again, block the request.
    • Fetch only content of the page using ?contentOnly=true parameter.
    • Render templates with fetched content.
    • Return response that contains generated html.

Performance Metrics

Screen-Shot-2020-01-12-at-22-26-24

Screen-Shot-2020-01-12-at-22-20-38

Screen-Shot-2020-01-12-at-22-20-55

This metrics measured by @philipwalton

Building locally

npm run build

You can run server with

npm run start

About

๐Ÿš€2x faster page loads and less payload sizes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published