pwa-studio icon indicating copy to clipboard operation
pwa-studio copied to clipboard

[Issue] Use pre-render to boost Largest Contentful Paint (LCP)

Open m2-assistant[bot] opened this issue 4 years ago • 2 comments

This issue is automatically created based on existing pull request: magento/pwa-studio#3090: Use pre-render to boost Larget Contentful Paint (LCP)


Description

This will add hydrate option when root element has children. This is a follow-up for requested default Rendertron Middleware support in #3058

This PR depends on this Rendertron PR https://github.com/GoogleChrome/rendertron/pull/654 Which allows to keep javascript tags so you can use rehydrate the page.

Acceptance

Verification Stakeholders

Specification

Verification Steps

  1. Spin up Rendertron based on this PR https://github.com/GoogleChrome/rendertron/pull/654 and run it with the following config.json
{
  "cache": "filesystem",
  "cacheConfig": {
    "cacheDurationMinutes": 120,
    "cacheMaxEntries": 50,
    "snapshotDir": "~/tools/rendertron/snapshots"
  },
  "stripSelectors": "",
  "port": "3000",
  "closeBrowser": true
}
  1. Add the following lines to your .env
RENDERTRON_URL=https://localhost:3000/render
RENDERTRON_USER_AGENTS="^((?!HeadlessChrome).)*$"
RENDERTRON_EXCLUDE_URL_PATTERN="graphql|\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)"
  1. When you now visit the page you get a pre-render response which can be re-hydrated.
  2. The config is set to use a cache layer so now you can use SEOSnap to use as a CacheWarmer
  3. When rendertron is not running it will automatically fallback to the default render functionality

Screenshots / Screen Captures

Pre-rendered

image

Not Pre-rendered

image

m2-assistant[bot] avatar Apr 07 '21 15:04 m2-assistant[bot]

@magento export issue to JIRA project PWA as Story

sirugh avatar Apr 07 '21 15:04 sirugh

:white_check_mark: Jira issue (https://jira.corp.magento.com/browse/PWA-1659) is successfully created for this issue.

github-jira-sync-bot avatar Apr 07 '21 15:04 github-jira-sync-bot