GithubHelp home page GithubHelp logo

io-compute-poc's Introduction

Fastly Image Optimizer fetch solution from undefined image source

This is a small app to be used to showcase how you could use compute to fetch images from "random" source and push them thru Fastly Image Optimizer and store them in cache for a nice user experience.

This code requires you to have a CDN service setup with IO enabled and a Fastly compute service that runs this code.

How to use

Deploy the code into fastly using the Fastly CLI. Make sure you have DynamicBackends enabled by Fastly Use a Fastly CDN configured to use the newly deployed compute service as a origin. Request the image thru the CDN

https://<cdn-service-dns>/<domain and image path> (without https:(/))

Example: https://edgeio.boman.church/upload.wikimedia.org/wikipedia/commons/7/70/Example.png

CDN will receive the request, if image is not in cache ask the compute service for the image. Compute service will fetch the image based on the URL/path in the request (assuming HTTPS currently). Compute service will forward the image to CDN that will transform the image using the parameters such as ?width=100&format=webp and serve the user.

Todo

  • Add security in the way of a header token to validate that this app should run and remove the token from the response.
  • Fix the loop issue.
  • Stream the file from Compute to origin to avoid running out of heapMemmory at 128mb if it's a really large image
  • Remove all response headers from the fetched image in the response to CDN to ensure IO works properly
  • Make sure QS's are handled properly from the incomming request to compute to the respones back to CDN where the transformation happens
  • Method for handling http and https (will this be required, fallback if HTTPS fails maby)

For more details about other starter kits for Compute, see the Fastly developer hub

Security issues

Please see our SECURITY.md for guidance on reporting security-related issues.

io-compute-poc's People

Contributors

nisseboman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.