Optimization tips for pushing React Redux to production
CDN via Rawgit
This free service turns your repos files to CDN files.
- If your files changes, then you need to place a random string as part of your files.
- Keep this string in a separate file.
- Use this the random string when request arrives.
Express.js code
router.get("*", (req, res) => {
const base = "https://cdn.rawgit.com/selfrefactor/ils/master/service/cdn/files"
res.render("index", {
bundle:`${base}/bundle-${cdnConfig.bundle}.js`,
db:cdnConfig.db,
style:`${base}/style-${cdnConfig.style}.css`,
title: "I Learn Smarter",
})
})
Pug code
doctype html
html(lang="en")
head
meta(charset="utf-8")
title= title
meta(http-equiv='X-UA-Compatible', content='IE=edge')
meta(http-equiv='Content-Type', content='text/html; charset=utf-8')
meta(name='viewport', content='width=device-width')
meta(name='application-name', content= pageDescription)
meta(name='description', content= pageDescription)
link(href='favicon.ico', type='image/x-icon', rel='shortcut icon')
link(rel='preload', href= style, as='style', onload="this.rel='stylesheet'")
body
#data-container(data-db= db)
#react-container
script(src= bundle)