Published: Updated:

Table of contents

If one needs to serve static files evenly fast to any device in the world then they are probably thinking about CDN.

Plan

  1. create S3 bucket
  2. create a “distribution” in AWS CloudFront for that bucket (how many times my colleagues keep calling it CloudFlare?)

Caveats

function handler(event) {
    var request = event.request;
    var uri = request.uri;

    // Check whether the URI is missing a file name.
    if (uri.endsWith('/')) {
        request.uri += 'index.html';
    }
    // Check whether the URI is missing a file extension.
    else if (!uri.includes('.')) {
        request.uri += '/index.html';
    }

    return request;
}
<head>
  <link rel="stylesheet" href="css/styles.css" />

  <script>
    /*to prevent Firefox FOUC, this must be here*/
    let FF_FOUC_FIX;
  </script>
</head>

Rate this page