DEV Community

Murahashi [Matt] Kenichi
Murahashi [Matt] Kenichi

Posted on

4 3

Programmable Edge

10 years ago, we said "database access is too slow." We used cache layer, memcached.

5 years ago, we said "access to web server is too slow." We used CDN, application cache.

2 years ago, we said "appCache is not flexible." We used ServiceWorker.

Now, we said "Edge (CDN included) is not flexible."

Introduction of fly

This is from fly readme,

Edge, this is edge, I want to create this by more programmable, and get more flexible.

Example 1

https://vanilla-terrier-972.edgeapp.net/

This is just proxy to https://www.moneyforward.vn .

This is getting-started from https://github.com/superfly/cdn#try-the-starter-app

import { backends, proxy, middleware, pipeline } from "@fly/cdn";

const mw = pipeline(
  middleware.httpsUpgrader,
  middleware.httpCache
)

const app = mw(
  proxy("https://www.moneyforward.vn")
);

fly.http.respondWith(app);
Enter fullscreen mode Exit fullscreen mode

I wrote this, and deployed to fly. I can create edge by easy way!

Example 2

Provided example

fly.http.respondWith(function(request){
   return new Response("Hello! We support whirled peas.", { status: 200})
 })
 // if you'd prefer to be service worker compatibility, this is also supported:
 // around addEventListener('fetch', function(event){})
Enter fullscreen mode Exit fullscreen mode

Example 3

Provided example

addEventListener('fetch', function (event) {
   event.respondWith(new Response('Redirecting',
     {
       headers: {
         'Location': 'https://fly.io/docs/apps/'
       },
       status: 302
     }
   ))
 })
Enter fullscreen mode Exit fullscreen mode

References

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
shaijut profile image
Shaiju T

What makes fly.io different from other cloud providers like AWS, Azure, Netlify. Is it the technology feature or the cost ? Also Do you have serverless technology ?

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay