servor icon indicating copy to clipboard operation
servor copied to clipboard

Support already encoded files (gz, br)

Open DeusProx opened this issue 3 years ago • 0 comments

Currently many file types like 'js', 'css', 'html', 'json', 'xml', 'svg' get automatically encoded as gzip and the Header content-encoding will be set to gzip. In my project I use esbuild with an compression plugin to automatically encode all bundles as brötli. Since servor doesn't check for gz or br file extension these files get served wrong.

  • Proposol 1: Check for file extensions gz and br and set the right content headers
    • Advantages: Very simple
    • Disadvantages: Not very flexibel
  • Proposal 2: Give the user the possibilitry to add configuration file which adds
    • Advantages:
      • Gives the power back to the user of the package to freely add headers depending on his needs
      • Also handles other use cases like shown in the example above
    • Disadvantages:
      • More Complex
    • Example: With other servers I could for example add an file like:
{
  "headers": [
    {
      "source": "dist/serviceWorker.js",
      "headers": [{ "key": "Service-Worker-Allowed", "value": "/" }]
    },
    {
      "source" : "dist/*.br",
      "headers" : [{ "key" : "Content-Encoding", "value" : "br" }]
    }
  ]
}

DeusProx avatar Aug 19 '22 23:08 DeusProx