Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for Cloudflare Pages deployment #353

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/deployment/cloudflare-pages.md
@@ -0,0 +1,52 @@
---
title: Cloudflare Pages | Deployment
---

# Cloudflare Pages

## Configure `manifest.webmanifest` mime type

You need to register the correct MIME type for the web manifest by adding a headers entry to your `_headers` file (see basic deployment below):
```
/manifest.webmanifest
Content-Type: application/manifest+json
```

## Cache-Control

As a general rule, files in `/assets/` can have a very long cache time, as everything in there should contain a hash in the filename.

Add row to your `_headers` file (see basic deployment below):

```
/
Cache-Control: public, max-age=0, s-maxage=0, must-revalidate

/assets/*
Cache-Control: public, max-age=31536000, immutable

/workbox-*
Cache-Control: public, max-age=31536000, immutable
```

## Configure http to https redirection

Cloudflare Pages will redirect automatically, so you don't worry about it.

## Basic deployment example

Add `_headers` file to the build output root directory. Note that your output root directory probably won't be the root of your project itself. For example, in a Vue 3 project you'd create this file at `public/_headers`.

```
/
Cache-Control: public, max-age=0, s-maxage=0, must-revalidate

/assets/*
Cache-Control: public, max-age=31536000, immutable

/workbox-*
Cache-Control: public, max-age=31536000, immutable

/manifest.webmanifest
Content-Type: application/manifest+json
```