You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
7
10
8
11
### What you can build
9
12
10
13
#### Static sites
14
+
11
15
Host and serve HTML, CSS, JavaScript, and media files directly from Cloudflare's network, ensuring fast loading times worldwide. This is ideal for blogs, landing pages, and documentation sites.
12
16
13
17
#### Full-stack applications
18
+
14
19
Combine asset hosting with Cloudflare Workers to power dynamic, interactive applications. Store and retrieve data using Cloudflare KV, D1, and R2 Storage, allowing you to serve both front-end assets and backend logic from a single Worker.
15
20
16
21
### Benefits
17
22
18
23
#### Global caching for faster performance
24
+
19
25
Cloudflare automatically caches static assets at data centers worldwide, reducing latency and improving load times by up to 2x for users everywhere.
20
26
21
27
#### Scalability without infrastructure management
28
+
22
29
Your applications scale automatically to handle high traffic without requiring you to provision or manage infrastructure. Cloudflare dynamically adjusts to demand in real time.
23
30
24
31
#### Unified deployment for static and dynamic content
32
+
25
33
Deploy front-end assets alongside server-side logic, all within Cloudflare Workers. This eliminates the need for a separate hosting provider and ensures a streamlined deployment process.
26
34
27
35
---
@@ -45,22 +53,30 @@ After these steps are completed, the User Worker's static assets will be live on
45
53
46
54
Before sending any file data, you need to tell Cloudflare which files you intend to upload. That list of files is called a manifest. Each item in the manifest includes:
47
55
48
-
* A file path (for example, `"/index.html"` or `"/assets/logo.png"`)
49
-
* A hash (32-hex characters) representing the file contents
50
-
* The file size in bytes
56
+
- A file path (for example, `"/index.html"` or `"/assets/logo.png"`)
57
+
- A hash (32-hex characters) representing the file contents
Cloudflare automatically de-duplicates identical asset hashes within the same
62
+
account. If an asset with the same hash has already been uploaded, it may be
63
+
shared across different User Workers **unless explicitly made unique**. If you
64
+
require full asset isolation, prepend asset hashes with a unique identifier
65
+
(for example, an account ID or Worker name).
66
+
</Aside>
51
67
52
68
#### Example manifest (JSON)
53
69
54
70
```json
55
71
{
56
-
"/index.html": {
57
-
"hash": "08f1dfda4574284ab3c21666d1ee8c7d4",
58
-
"size": 1234
59
-
},
60
-
"/styles.css": {
61
-
"hash": "36b8be012ee77df5f269b11b975611d3",
62
-
"size": 5678
63
-
}
72
+
"/index.html": {
73
+
"hash": "08f1dfda4574284ab3c21666d1ee8c7d4",
74
+
"size": 1234
75
+
},
76
+
"/styles.css": {
77
+
"hash": "36b8be012ee77df5f269b11b975611d3",
78
+
"size": 5678
79
+
}
64
80
}
65
81
```
66
82
@@ -71,8 +87,9 @@ POST /accounts/{account_id}/workers/dispatch/namespaces/{namespace}/scripts/{scr
71
87
```
72
88
73
89
Path Parameters:
74
-
*`namespace`: Name of the Workers for Platforms dispatch namespace
75
-
*`script_name`: Name of the User Worker
90
+
91
+
-`namespace`: Name of the Workers for Platforms dispatch namespace
92
+
-`script_name`: Name of the User Worker
76
93
77
94
In the request body, include a JSON object listing each file path along with its hash and size. This helps Cloudflare identify which files you intend to upload and allows Cloudflare to check if any of them are already stored.
78
95
@@ -105,8 +122,8 @@ You can compute a SHA-256 digest of the file contents, then truncate or otherwis
105
122
106
123
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:
107
124
108
-
*`jwt`: An upload token (valid for 1 hour) which will be used in the API request to upload the file contents (Step 2).
109
-
*`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.
125
+
-`jwt`: An upload token (valid for 1 hour) which will be used in the API request to upload the file contents (Step 2).
126
+
-`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.
110
127
111
128
:::note
112
129
This step alone does not store files on Cloudflare. You must upload the actual file data in the next step.
*`<upload-session-token>` is the token from step 1's assets-upload-session response
163
-
*`<BASE64_OF_INDEX_HTML>` is the Base64-encoded content of index.html
164
-
*`<BASE64_OF_STYLES_CSS>` is the Base64-encoded content of styles.css
180
+
-`<upload-session-token>` is the token from step 1's assets-upload-session response
181
+
-`<BASE64_OF_INDEX_HTML>` is the Base64-encoded content of index.html
182
+
-`<BASE64_OF_STYLES_CSS>` is the Base64-encoded content of styles.css
165
183
166
184
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.
167
185
168
186
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.
0 commit comments