StaticDeploy

StaticDeploy

  • Docs
  • GitHub
  • Privacy

›Guides

Getting started

  • Quickstart
  • Overview
  • Apps configuration
  • CI/CD Workflow

Guides

  • Deploying StaticDeploy with docker
  • Deploying static apps
  • Using a client-side router
  • Serving assets with custom headers
  • Using a fallback asset
  • Configuring JWT identity providers
  • Configuring OpenID Connect identity providers

Use with

  • Create React App
  • Vue CLI

Reference

  • Entities
  • Authentication and authorization
  • Using StaticDeploy's CLI
  • How StaticDeploy routes requests
  • Architecture

Serving assets with custom headers

StaticDeploy allows you to specify custom headers to use when serving assets. For example, if you have a bundle containing assets index.html and index.js, you can tell StaticDeploy to serve index.html with header Cache-Control: must-revalidate, and index.js with Cache-Control: public.

Custom headers are specified per-asset when creating a bundle, using the headers options of the StaticDeploy CLI bundle command. Example (using a config file):

module.exports = {
  bundle: {
    // ... other options
    headers: {
      "**/*.html": {
        "Cache-Control": "must-revalidate",
      },
      "**/*.js": {
        "Cache-Control": "public",
      },
    },
  },
};

The headers option is a (asset matcher, headers) map. asset matcher is a glob pattern used to match assets' paths, while the headers object containing the headers to use when serving the matching assets.

Common use cases for custom headers are:

  • specifying caching policies
  • specifying security headers
  • overriding an asset's Content-Type
← Using a client-side routerUsing a fallback asset →