Skip to content

Commit 3c548bf

Browse files
Style guide changes and replace CF's edge for global network
1 parent 5de5d05 commit 3c548bf

File tree

1 file changed

+17
-14
lines changed
  • src/content/docs/cloudflare-for-platforms/workers-for-platforms/configuration

1 file changed

+17
-14
lines changed

src/content/docs/cloudflare-for-platforms/workers-for-platforms/configuration/static-assets.mdx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
pcx_content_type: concept
3-
title: Static Assets
3+
title: Static assets
44
---
55
Workers for Platforms lets you deploy front-end applications at scale. By hosting static assets on Cloudflare's global network, you can deliver faster load times worldwide and eliminate the need for external infrastructure. You can also combine these static assets with dynamic logic in Cloudflare Workers, providing a full-stack experience for your customers.
66

@@ -25,11 +25,11 @@ Deploy front-end assets alongside server-side logic, all within Cloudflare Worke
2525

2626
---
2727

28-
## Deploying static assets to User Workers
28+
## Deploy static assets to User Workers
2929

30-
It's common that as the Platform, you will be responsible for uploading static assets on behalf of your end users. This often looks like this:
30+
It is common that, as the Platform, you will be responsible for uploading static assets on behalf of your end users. This often looks like this:
3131

32-
1. User uploads files (HTML, CSS, images) through your interface.
32+
1. Your user uploads files (HTML, CSS, images) through your interface.
3333
2. Your platform interacts with the Workers for Platforms APIs to attach the static assets to the User Worker script.
3434

3535
Once you receive the static files from your users (for a new or updated site), complete the following steps to attach the files to the corresponding User Worker:
@@ -38,7 +38,7 @@ Once you receive the static files from your users (for a new or updated site), c
3838
2. Upload file contents
3939
3. Deploy/Update the Worker
4040

41-
After these steps are completed, the User Worker's static assets will be live on Cloudflare's edge.
41+
After these steps are completed, the User Worker's static assets will be live on the Cloudflare's global network.
4242

4343
### 1. Create an Upload Session
4444

@@ -63,7 +63,7 @@ Before sending any file data, you need to tell Cloudflare which files you intend
6363
}
6464
```
6565

66-
To start the upload process, send a POST request to the Create Assets Upload Session [API endpoint](/api/resources/workers_for_platforms/subresources/dispatch/subresources/namespaces/subresources/scripts/subresources/asset_upload/methods/create/)
66+
To start the upload process, send a POST request to the Create Assets Upload Session [API endpoint](/api/resources/workers_for_platforms/subresources/dispatch/subresources/namespaces/subresources/scripts/subresources/asset_upload/methods/create/).
6767

6868
```bash
6969
POST /accounts/{account_id}/workers/dispatch/namespaces/{namespace}/scripts/{script_name}/assets-upload-session
@@ -103,10 +103,13 @@ You can compute a SHA-256 digest of the file contents, then truncate or otherwis
103103
**API Response**
104104

105105
If all the files are already stored on Cloudflare, the response will only return the JWT token. If new or updated files are needed, the response will return:
106-
* `jwt`: An upload token (valid for 1 hour) which will be used in the API request to upload the file contents (Step 2)
106+
107+
* `jwt`: An upload token (valid for 1 hour) which will be used in the API request to upload the file contents (Step 2).
107108
* `buckets`: An array of file-hash groups indicating which files to upload together. Files that have been recently uploaded won't appear in buckets, since Cloudflare already has them.
108109

109-
**Note**: This step alone does not store files on Cloudflare. You must upload the actual file data in the next step.
110+
:::note
111+
This step alone does not store files on Cloudflare. You must upload the actual file data in the next step.
112+
:::
110113

111114
### 2. Upload File Contents
112115

@@ -129,7 +132,7 @@ This token is valid for one hour and must be supplied for each upload request to
129132
**File fields (multipart/form-data)**
130133
You must send the files as multipart/form-data with base64-encoded content:
131134

132-
* Field name: The file hash (for example, "36b8be012ee77df5f269b11b975611d3")
135+
* Field name: The file hash (for example, `36b8be012ee77df5f269b11b975611d3`)
133136
* Field value: A Base64-encoded string of the file's raw bytes
134137

135138
**Example: Uploading multiple files within a single bucket**
@@ -161,7 +164,7 @@ curl -X POST \
161164

162165
If you have multiple buckets (for example, `[["hashA"], ["hashB"], ["hashC"]]`), you might need to repeat this process for each bucket, making one request per bucket group.
163166

164-
Once every file in the manifest has been uploaded, a status code of 201 will be returned, with the `jwt` field present. This JWT is a final "completion" token which can be used to create a deployment of a Worker with this set of assets. This completion token is valid for 1 hour.
167+
Once every file in the manifest has been uploaded, a status code of `201` will be returned, with the `jwt` field present. This JWT is a final "completion" token which can be used to create a deployment of a Worker with this set of assets. This completion token is valid for 1 hour.
165168

166169
```json
167170
{
@@ -176,11 +179,11 @@ Once every file in the manifest has been uploaded, a status code of 201 will be
176179

177180
`<completion-token>` indicates that Cloudflare has successfully received and stored the file contents specified by your manifest. You will use this `<completion-token>` in Step 3 to finalize the attachment of these files to the Worker.
178181

179-
### 3. Deploy the User Worker with Static Assets
182+
### 3. Deploy the User Worker with static assets
180183

181184
Now that Cloudflare has all the files it needs (from the previous upload steps), you must attach them to the User Worker by making a PUT request to the [Upload User Worker API](https://developers.cloudflare.com/api/resources/workers_for_platforms/subresources/dispatch/subresources/namespaces/subresources/scripts/methods/update/). This final step links the static assets to the User Worker using the completion token you received after uploading file contents.
182185

183-
You can also specify any optional settings under the assets.config field to customize how your files are served (for example, to handle trailing slashes in HTML paths).
186+
You can also specify any optional settings under the `assets.config` field to customize how your files are served (for example, to handle trailing slashes in HTML paths).
184187

185188
**API request example:**
186189

@@ -204,7 +207,7 @@ curl -X PUT \
204207

205208
* The `"jwt": "<completion-token>"` links the newly uploaded files to the Worker
206209
* Including "html_handling" (or other fields under "config") is optional and can customize how static files are served
207-
* If the user's Worker code hasn't changed, you can omit the code file or re-upload the same index.js
210+
* If the user's Worker code has not changed, you can omit the code file or re-upload the same index.js
208211

209212
Once this PUT request succeeds, the files are served on the User Worker. Requests routed to that Worker will serve the new or updated static assets.
210213

@@ -242,7 +245,7 @@ export default {
242245
},
243246
};
244247
```
245-
### 2. Deploy the User Worker with the Static Assets
248+
### 2. Deploy the User Worker with the static assets
246249

247250
Run Wrangler to publish both your Worker code and the static assets:
248251

0 commit comments

Comments
 (0)