DEV Community 👩‍💻👨‍💻

Murahashi [Matt] Kenichi
Murahashi [Matt] Kenichi

Posted on

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

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 ?

Create an Account! The only reason people scroll to the bottom...  
is because they want to read more.

Create an account to bookmark, comment, and react to articles that interest you.