Giter Site home page Giter Site logo

rsoorajs / booster.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sbbqq/libertyhosts

1.0 1.0 0.0 1.6 MB

booster.js is a speed and performance optimizier for your website, delivering fast web experiences to users.

Home Page: https://booster.js.org

License: MIT License

JavaScript 9.69% TypeScript 90.31%

booster.js's Introduction

Header

Rocket Booster is the edge-rendered speed booster for web applications, storage platforms, and RESTful APIs. It's a reverse proxy that sits in front of web servers, intercepting requests from clients.

  • Performance: Deploy to a network of data centers powered by Cloudflare.
  • Serverless: No VMs, no servers, and no containers to spin up or manage.
  • Optimization: Minify HTML/CSS/JS files, compress images, cache static assets.
  • Cross-Origin: Add necessary CORS headers to the proxied response.
  • Firewall: Block traffics from specific IP addresses, countries, or User-Agent.
  • Network: Enable HTTPS, HTTP/3 (with QUIC), TLS 1.3, and IPv6 for web applications.
  • Load Balance: Distribute incoming traffics evenly among different servers.

Build and Deploy

  1. Install Wrangler CLI
npm install @cloudflare/wrangler -g
  1. Generate from rocket-booster-template
wrangler generate booster https://github.com/rocket-booster/rocket-booster-template
  1. Install dependencies
cd booster

npm install
  1. Authenticate Wrangler with a Cloudflare API Token
wrangler login

wrangler config
  1. Edit src/index.js to configure Rocket Booster

  2. Build and publish to Cloudflare Workers

wrangler build

wrangler publish

Configuration

Upstream

  • domain: The domain name of the upstream server.
  • protocol: The protocol scheme of the upstream server. (Optional)
  • port: The port of the upstream server. (Optional)
  • path: The path of the upstream server. (Optional)
  • timeout: The maximum wait time on a request to the upstream server. (Optional)
const config = {
  upstream: {
    domain: 'en.wikipedia.org',
    protocol: 'https',
    port: 443,
    path: '/',
    timeout: 10000,
  },
  /* ... */
};

To load balance HTTP traffic to a group of servers, pass an array of server objects to upstream. Each request will be passed to a randomly selected server.

const config = {
  upstream: [
    {
      domain: 's1.example.com',
      protocol: 'https',
    },
    {
      domain: 's2.example.com',
      protocol: 'https',
    },
    {
      domain: 's3.example.com',
      protocol: 'https',
    },
  ],
  /* ... */
};

Optimization

  • minify: Remove unnecessary characters (like whitespace, comments, etc.) from HTML, CSS, and JavaScript files.
  • mirage: Detect screen size and connection speed to optimally deliver images for the current browser window.
const config = {
  /* ... */
  optimization: {
    mirage: true,
    minify: {
      javascript: true,
      css: true,
      html: true,
    },
  },
};

Several optimizations are enabled by default.

  • Brotli: Speed up page load times for visitor’s HTTPS traffic by applying Brotli compression.
  • HTTP/2: Improve page load time by connection multiplexing, header compression, and server push.
  • HTTP/3 with QUIC: Accelerate HTTP requests by using QUIC, which provides encryption and performance improvements compared to TCP and TLS.
  • 0-RTT Connection Resumption: Improve performance for clients who have previously connected to the website.

Cross-Origin Resource Sharing (CORS)

  • origins: The origins to allow requests from.
  • methods: The methods which the origins are allowed to access.
  • allowHeaders: Headers to accept from the client.
  • exposeHeaders: Give explicit permissions for the client to read headers in CORS responses.
  • credentials: Inject the Access-Control-Allow-Credentials header in responses.
  • maxAge: Specify the value in seconds for how long the response to the preflight request can be cached for.
const config = {
  /* ... */
  cors: {
    origins: [
      'https://example.com',
    ],
    methods: [
      'GET',
      'POST',
    ],
    allowHeaders: [
      'X-Forwarded-For',
    ],
    exposeHeaders: [
      'X-Forwarded-For',
    ],
    credentials: true,
    maxAge: 86400,
  },
};

Contribute

  • Feature Request: Create an issue with the Feature request template.
  • Bug Reports: Create an issue with the Bug report template.
  • Improvements to the booster.js: Fork the repository, edit code, deploy it to Cloudflare Workers, and then create a pull request.
  • Add Config Examples: Fork the repository, write an example config for any website, save it to the examples directory, and then create a pull request.

Current contributors

Contributors

Support Rocket Booster

We accept donations through these channels:

  • Buy Me a Coffee
  • Bitcoin: 1Eb4n6eEyyKjbu3feA9oAQAnZo1K46UvXN
  • Ethereum: 0x16145d98625c0b2aa265773970ca090bf783d5ae

booster.js's People

Contributors

xiaoyang-sde avatar dependabot[bot] avatar cbwang2016 avatar jimmytinsley avatar markliniubility avatar developerdong avatar azhuge233 avatar liberty-song avatar

Stargazers

Octavian 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.