Breaking Down Best Practices for JAMstack
A PRESENTATION BY JEMIMA ABU
Jemima Abu:
Here’s what we gon learn:
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
What’s a CDN?
Content Delivery Network
Connected network of distributed servers
Stores your site’s assets on their servers
Browser requests are made to the CDN
Content is returned from the server closest to the user
How To Setup A Content Delivery Network
<img src=”my-url/images/img.jpg />�<img src=”cdn-url/images/img.jpg/>
Some CDN Providers
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
Using Version Control
Keep track of changes made in code
Stores code in online repository for easy access
Allows for easier collaboration on projects
Can have multiple branches of code
Using Version Control
Linking Version Control to Deployment Platform
Some Version Control Systems
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
Automated Builds
Build - a whole bunch of processes at the final stage of an app
running tests, compiling files, updating databases etc
server is notified when a new build is required
server builds the project, updates the CDNs and the site is live
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
Build Tools
automation of repetitive tasks
converting and compiling stylesheets
minifying stylesheets and scripts
bundling modules
Using Modern Build Tools
Using Modern Build Tools
Source: https://hackernoon.com/javascript-build-tools-and-automation-systems-9589c5c91ebe
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
Atomic Deploy
Atomicity - either completely executed or not executed at all
Update live server only after successful deployment
Rolls back to previous release on failed deployment
So, like, no downtime between releases
Setting Up Atomic Deployment
But why would you want to do a thing like that?!
Atomic Deployment Providers
Best Practices
Content delivery network | Everything in version control | Automated builds |
Modern Build Tools | Atomic deploys | Cache invalidation |
Cache Invalidation
removing or replacing content stored in cache
purge - remove content from caching proxy immediately
refresh - fetches requested content directly from the app
ban - reference to cached content is added to ban list
“ There are only two hard things in Computer Science: cache invalidation and naming things. ”
— PHIL KARLTON
How Exactly Do We Invalidate Cache?
Alternatives to Cache Invalidation
Set cached content to expire quickly by reducing time-to-live
validate the freshness of cached content at every request
don’t cache content at all
Basically
Demo…?
Resources
That’s All Folks!
www.jemimaabu.com�Website
@jemimaabu�Everywhere else