SlideShare a Scribd company logo
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript
無法被搜尋引擎正確索引的問題
Kewang
● 王慕羣 Kewang
● Java / JavaScript
● HBase / PostgreSQL / MongoDB / ElasticSearch
● Git / DevOps
●
熱愛開源
LinkedinLinkedin kewangtwkewangtw
SlideShareSlideShare kewangkewang
GmailGmail cpckewangcpckewang
FacebookFacebook Kewang 的資訊進化論Kewang 的資訊進化論
devopsday taipeidevopsday taipei '17'17
hadoopconhadoopcon '14 '15'14 '15
mopconmopcon '14'14
jcconfjcconf '16 '17 '18'16 '17 '18
modernwebmodernweb '18 '19'18 '19
GitHubGitHub kewangkewang
FunlidayFunliday kewangkewang
coscupcoscup '20'20
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
5
Agenda
● CSR & SSR
● Why SSR?
● How SSR?
● What is prerender?
● pppr - enhanced prerender
6
CSR & SSR
7
Rendered page
8
Rendered page
9
CSR - client side rendering
10
CSR - client side rendering
總行數就是 12 行
11
SSR - server side rendering
12
SSR - server side rendering
總行數超過 500 行
13
14
15
16
17
18
19
20
21
22
23
Why SSR?
24
Social media
25
Social media
26
Social media
27
Meta tags
28
Meta tags
29
Meta tags
30
Meta tags
31
SEO
32
SEO
33
SERP - Search Engine Results Page
34
SERP - Search Engine Results Page
35
How SSR?
36
JavaScript framework SSR solutions
● Vue.js
– Nuxt.js
● Angular
– Angular Universal
● React
– Next.js
37
Next.js SSR example
38
Common SSR steps
1. Write server code at client page
2. Modify webpack build flow
39
vue-hackernews-2.0
40
vue-hackernews-2.0
41
vue-hackernews-2.0
42
Common SSR steps - server.js
43
Common SSR steps - server.js
比對出合適的路由
44
Common SSR steps - server.js
比對出合適的路由
對應正確的路徑參數
45
Common SSR steps - server.js
比對出合適的路由
對應正確的路徑參數
取得對應的 metadata
46
Common SSR steps - server.js
比對出合適的路由
對應正確的路徑參數
回傳結果
取得對應的 metadata
47
Common SSR steps - metadata.js
48
Common SSR steps - metadata.js
不想被搜尋引擎 index
49
Common SSR steps - webpack.js
50
SSR cons
51
SSR cons
● Code complexity increases
52
SSR cons
● Code complexity increases
● Can't separate server and client code
53
SSR cons
● Code complexity increases
● Can't separate server and client code
● Every route need an extra API to generate data
54
SSR cons
● Code complexity increases
● Can't separate server and client code
● Every route need an extra API to generate data
● Avoid to run `window` or other DOM objects at server code
55
SSR cons
● Code complexity increases
● Can't separate server and client code
● Every route need an extra API to generate data
● Avoid to run `window` or other DOM objects at server code
● You need a full-stack engineer
56
What is prerender?
57
Introduction
58
System diagram
client
CDN
puppeteerNginx
Web server
59
System diagram
client
CDN
puppeteersend request Nginx
Web server
60
System diagram
client
CDN
puppeteersend request Nginx
Web server
non-crawler
61
System diagram
client
CDN
puppeteersend request Nginx
Web server
crawler
non-crawler
62
System diagram
client
CDN
puppeteersend request Nginx
Web server
crawler
non-crawler
if no cache
63
System diagram
client
CDN
puppeteersend request Nginx
Web server
crawler
non-crawler
if no cache
request
64
Reverse Proxy - Nginx
65
Reverse Proxy - Nginx
crawler
66
Reverse Proxy - Nginx
crawler
forward to prerender
67
Reverse Proxy - Nginx
crawler
forward to prerender
direct to origin
68
Pyramid of Puppeteer
69
Pyramid of Puppeteer
70
Pyramid of Puppeteer
71
Pyramid of Puppeteer
72
Pyramid of Puppeteer
73
pppr - enhanced prerender
74
pppr - enhanced prerender
https://github.com/funliday/pppr
75
DEMO
76
Zero configuration
77
LRU cache
78
Retry times
79
Endpoint
80
Callback
81
If you want to build a prerender service
82
Without cache
expressjs
clientclientclientclientclient
83
Without cache
expressjs
clientclientclientclientclient
84
Without cache
expressjs
puppeteer
clientclientclientclientclient
85
With cache
expressjs
clientclientclientclientclient
86
With cache
expressjs
clientclientclientclientclient
87
With cache
expressjs
has cache
clientclientclientclientclient
88
With cache
expressjs
has cache
N
clientclientclientclientclient
89
With cache
expressjs
puppeteer
has cache
N
clientclientclientclientclient
90
With cache
expressjs
puppeteer
has cache
N Y
clientclientclientclientclient
91
With cache
expressjs
puppeteer
has cache
N
return
cache
Y
clientclientclientclientclient
92
Without open new page per request
client
93
Without open new page per request
client
A page
94
Without open new page per request
client
A page
B page
95
Without open new page per request
client
A page
B rendered
B page
96
Without open new page per request
client
A page
B rendered
B page
A unexpected error
97
With open new page per request
client
98
With open new page per request
client
A page
99
With open new page per request
client
A page
B page
100
With open new page per request
client
A page
B rendered
B page
101
With open new page per request
client
A page
B rendered
B page
A rendered
102
Modify user agent
103
Modify user agent
HeadlessChrome
104
Modify user agent
HeadlessChrome
105
Modify user agent
Chrome
106
Without handle redirection
expressjs
puppeteer
HTTP client
107
Without handle redirection
expressjs
puppeteer
HTTP client
108
Without handle redirection
expressjs
puppeteer
HTTP client
status 30x
109
Without handle redirection
expressjs
puppeteer
HTTP client
status 30x
N
110
Without handle redirection
expressjs
puppeteer
HTTP client
renderer
status 30x
N
111
Without handle redirection
expressjs
puppeteer
HTTP client
renderer
status 30x
Y
N
112
With handle redirection
expressjs
puppeteer
HTTP client
113
With handle redirection
expressjs
puppeteer
HTTP client
114
With handle redirection
expressjs
puppeteer
HTTP client
status 30x
115
With handle redirection
expressjs
puppeteer
HTTP client
status 30x
N
116
With handle redirection
expressjs
puppeteer
HTTP client
renderer
status 30x
N
117
With handle redirection
expressjs
puppeteer
HTTP client
renderer
status 30x
YN
118
With handle redirection
expressjs
puppeteer
HTTP client
renderer
status 30x
return 30x
YN
119
Handle query string
120
Handle query string
取得除了 url 外的其他參數
121
Handle query string
取得除了 url 外的其他參數
重組成完整的 URL
122
Conclusion
123
Conclusion
124
Conclusion
● Client solution: SSR or Framework solution
125
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
126
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
127
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
128
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
– Cache API
129
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
– Cache API
– Full-stack engineer
130
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
– Cache API
– Full-stack engineer
● Server solution: pppr
131
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
– Cache API
– Full-stack engineer
● Server solution: pppr
– Pure server code and configuration
132
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
– Cache API
– Full-stack engineer
● Server solution: pppr
– Pure server code and configuration
– Cache page and CDN
133
Conclusion
● Client solution: SSR or Framework solution
– Universal JavaScript
– Extra API
– Mix server & client code at one page
– Cache API
– Full-stack engineer
● Server solution: pppr
– Pure server code and configuration
– Cache page and CDN
– More and more user-agents
134
References
●
Rendering on the Web
●
Client-Side, Static, and Server-Side Rendering
●
React and Server Side Rendering (SSR)
●
vuejs/vue-hackernews-2.0
●
Implement dynamic rendering with Rendertron
●
Puppeteer Tutorial
●
Prerender in the Cloud
●
prerender 1粉絲頁文章
●
prerender 2粉絲頁文章
●
prerender 3粉絲頁文章
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題

More Related Content

PDF
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
PDF
如何使用 iframe 製作一個易於更新及更安全的前端套件
PDF
Kubernetes at Datadog Scale
PPTX
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
PDF
Rails Caching Secrets from the Edge
PDF
Load Balancing with Nginx
PDF
Caching the Uncacheable: Leveraging Your CDN to Cache Dynamic Content
PDF
How to monitor NGINX
大解密!用 PostgreSQL 提升 350 倍的 Funliday 推薦景點計算速度
如何使用 iframe 製作一個易於更新及更安全的前端套件
Kubernetes at Datadog Scale
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Rails Caching Secrets from the Edge
Load Balancing with Nginx
Caching the Uncacheable: Leveraging Your CDN to Cache Dynamic Content
How to monitor NGINX

What's hot (20)

PPTX
Solving anything in VCL
PDF
Front End Performance
PDF
Tips for going fast in a slow world: Michael May at OSCON 2015
PDF
Site Performance Optimization for Joomla #jwc13
KEY
Deploying Plack Web Applications: OSCON 2011
PDF
Fisl - Deployment
PDF
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
PDF
How to test code with mruby
PDF
How To Set Up SQL Load Balancing with HAProxy - Slides
PDF
From pets to cattle - powered by CoreOS, docker, Mesos & nginx
KEY
Nginx - Tips and Tricks.
PDF
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
PDF
Content Caching with NGINX and NGINX Plus
PPTX
Learn nginx in 90mins
PDF
Design & Performance - Steve Souders at Fastly Altitude 2015
PPTX
5 things you didn't know nginx could do
PDF
Load Balancing Applications with NGINX in a CoreOS Cluster
PDF
(Re)discover your AEM
PDF
How to stay sane during your Vagrant journey
PDF
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
Solving anything in VCL
Front End Performance
Tips for going fast in a slow world: Michael May at OSCON 2015
Site Performance Optimization for Joomla #jwc13
Deploying Plack Web Applications: OSCON 2011
Fisl - Deployment
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
How to test code with mruby
How To Set Up SQL Load Balancing with HAProxy - Slides
From pets to cattle - powered by CoreOS, docker, Mesos & nginx
Nginx - Tips and Tricks.
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
Content Caching with NGINX and NGINX Plus
Learn nginx in 90mins
Design & Performance - Steve Souders at Fastly Altitude 2015
5 things you didn't know nginx could do
Load Balancing Applications with NGINX in a CoreOS Cluster
(Re)discover your AEM
How to stay sane during your Vagrant journey
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
Ad

Similar to pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題 (20)

PPTX
Build Fast WordPress Site With Gatsby
PDF
Capybara with Rspec
PDF
GraphQL Bangkok Meetup 6.0
PDF
Isomorphic React Applications: Performance And Scalability
PPTX
Service workers - Forza lavoro al servizio della tua Performance
PDF
Bringing the JAMstack to the Enterprise
ODP
Deployments with rails
PDF
Airframe RPC
PDF
Design a scalable site: Problem and solutions
PDF
Cocktail of Environments. How to Mix Test and Development Environments and St...
PDF
Writing Tools using WebKit
PPTX
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
PDF
Grunt.js and Yeoman, Continous Integration
PDF
Angularjs practical project experiences with javascript development in a bank
PPTX
Cold fusion is racecar fast
PDF
When it all GOes right
PDF
Docker for mac & local developer environment optimization
PPTX
WebDev Simplified React.js.pptx
PDF
Converting Your Dev Environment to a Docker Stack - Cascadia
PDF
AP4R on RubyKaigi2007 (English only)
Build Fast WordPress Site With Gatsby
Capybara with Rspec
GraphQL Bangkok Meetup 6.0
Isomorphic React Applications: Performance And Scalability
Service workers - Forza lavoro al servizio della tua Performance
Bringing the JAMstack to the Enterprise
Deployments with rails
Airframe RPC
Design a scalable site: Problem and solutions
Cocktail of Environments. How to Mix Test and Development Environments and St...
Writing Tools using WebKit
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Grunt.js and Yeoman, Continous Integration
Angularjs practical project experiences with javascript development in a bank
Cold fusion is racecar fast
When it all GOes right
Docker for mac & local developer environment optimization
WebDev Simplified React.js.pptx
Converting Your Dev Environment to a Docker Stack - Cascadia
AP4R on RubyKaigi2007 (English only)
Ad

More from Mu Chun Wang (20)

PDF
如何在有限資源下實現十年的後端服務演進
PDF
深入淺出 autocomplete
PDF
你畢業後要任職的軟體業到底都在做些什麼事
PDF
網路服務就是一連串搜尋的集合體
PDF
老司機帶你上手 PostgreSQL 關聯式資料庫系統
PDF
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
PDF
Funliday 新創生活甘苦談
PDF
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
PDF
Google Maps 開始收費了該怎麼辦?
PDF
Git 可以做到的事
PDF
那些大家常忽略的 Cache-Control
PDF
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
PDF
如何與全世界分享你的 Library
PDF
如何與 Git 優雅地在樹上唱歌
PDF
API Blueprint - API 文件規範的三大領頭之一
PDF
團體共同協作與版本管理 - 01認識共同協作
PDF
Git 經驗分享
PDF
手把手教你如何串接 Log 到各種網路服務
PDF
你有想過畢業九年後的你會變什麼樣子嗎?
PDF
HR Search - 輕鬆管理面試者
如何在有限資源下實現十年的後端服務演進
深入淺出 autocomplete
你畢業後要任職的軟體業到底都在做些什麼事
網路服務就是一連串搜尋的集合體
老司機帶你上手 PostgreSQL 關聯式資料庫系統
使用 PostgreSQL 及 MongoDB 從零開始建置社群必備的按讚追蹤功能
Funliday 新創生活甘苦談
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
Google Maps 開始收費了該怎麼辦?
Git 可以做到的事
那些大家常忽略的 Cache-Control
如何利用 OpenAPI 及 WebHooks 讓老舊的網路服務也可程式化
如何與全世界分享你的 Library
如何與 Git 優雅地在樹上唱歌
API Blueprint - API 文件規範的三大領頭之一
團體共同協作與版本管理 - 01認識共同協作
Git 經驗分享
手把手教你如何串接 Log 到各種網路服務
你有想過畢業九年後的你會變什麼樣子嗎?
HR Search - 輕鬆管理面試者

Recently uploaded (20)

PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
AI in Product Development-omnex systems
PPTX
ai tools demonstartion for schools and inter college
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
top salesforce developer skills in 2025.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
System and Network Administraation Chapter 3
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
AI in Product Development-omnex systems
ai tools demonstartion for schools and inter college
How Creative Agencies Leverage Project Management Software.pdf
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
top salesforce developer skills in 2025.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
System and Network Administraation Chapter 3
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Understanding Forklifts - TECH EHS Solution
How to Migrate SBCGlobal Email to Yahoo Easily
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題