Level up your headless CMS apps with edge computing
Caching and other optimization methods can only get you that far when it comes to performance. A content delivery network (CDN) is essential to take your websites and applications beyond the results achievable with those approaches. Often, CDNs are only used to redistribute static files across the globe. That’s great as well, but they offer much more.
Table of contents
Edge computing as a service
Edge computing is an approach where parts or entire applications are hosted on the edge of the network. The edge being CDN edge nodes. You don’t have to start rewriting your code to leverage edge computing or cloud computing in your project. There is a range of complementary services that offer edge computing as a service. You can use Uniform.dev for personalization, Prerender.io for generating a static version of your website, or Fly.io for providing edge computing for Heroku apps. These services bring you the benefit of edge computing without having to start from scratch.
Distributing your code
The next step up from using a 3rd party service is distributing your own code. All major CDN providers offer code execution on their edge nodes. Be it Fastly, Cloudflare, or AWS. If you're using a CDN already, check its support of edge computing use cases. CDN providers will have extensive documentation on how to deploy code into their nodes. Their tooling will also allow you to do so as part of your DevOps process.
Main edge computing techniques
We can simplify distributed computing to two main techniques.
- You can move the entire app or parts of it to the edge. For example, instead of generating PDFs server-side, you can off-load it to the CDN. This technique requires more initial code changes. You might need to change your application architecture as more complex business logic is moved to the edge.
- You can manipulate the output data (HTML) of your website or app (JSON or other) close to your users. This technique often requires minimum to no code changes in your app. It also gives you quick wins, which customers often seek.
Let’s focus on quick-win scenarios with a headless CMS – SEO improvements and security!
A big area where edge computing can help is rolling out SEO experiments without code changes.
- Rolling out the
hreflangattribute on the whole website is a breeze.
- You can rewrite and thus redirect legacy URLs to a different sub-domain.
- Your code can detect social media crawlers and return optimized metadata for social sharing on those platforms.
- It’s possible to pre-interpret code for crawlers if your application or web is a dynamic single-page application.
If your SEO experiments succeed, you can then implement them in your core codebase.
Edge computing can reduce your attack surface by reducing the amount of information attackers can mine from your front-end code. You can:
- Rewrite third-party domains, so attackers are unaware of the used technology stack.
- Change the domain assets are served from.
- Roll out security headers reliably across all pages without changing the codebase.
- Use edge providers to protect you from DDoS attacks by enabling SSL on all pages with one checkbox – you don’t even have to supply a certificate in some cases.
- Hide any confidential information, such as which microservices you're using.
Moving parts of your application to the edge
So far we’ve covered common web use cases for edge computing, so what are the more advanced applications? Edge computing could host almost any piece of your web or application on the edge. To give some examples, you could:
- Implement personalization based on user context.
- Generate (personalized) images, SVGs, PDFs on the fly.
- Orchestrate and combine APIs from multiple sources into one master JSON response to be consumed by your applications.
- Leverage A/B testing close to your customers.
- Enable dynamic functionality on static websites (for example pesky shopping carts and currently logged-in users’ information).
As you can see, edge computing applications are wide, and each of these use cases could be enough for a separate article. Let us know via the chat button if you’d like to explore any of the mentioned use cases in depth!
- Check out how a headless CMS fits into an AWS (Amazon Web Services).
- Integrate Kontent with Uniform to bring personalization to the edge.
- A great example of edge computing is processing image transformations in Kontent.