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
{{ message }}
This repository was archived by the owner on Apr 15, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: guides/caching.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ To cache responses at edge you need to create an [environment](environments). Ea
8
8
9
9
## L1 and L2 Caches
10
10
11
-
Each edge point-of-presence (POP) has its own L1 cache. If a request cannot be fulfilled from the L1 cache, the XDN will attempt to fulfill the request from a single global L2 cache POP in order to maximize your effective cache hit ratio. There is very little difference in time to first byte for responses served from the L1 vs L2 cache. In either case the response is served nearly instantly (typically 25-100ms). Concurrent requests for the same URL on different POPs that result in a cache miss will be coalesced at the L2 cache. This means that only one request at a time for each cacheable URL will reach your origin servers.
11
+
Each edge point-of-presence (POP) has its own L1 cache. If a request cannot be fulfilled from the L1 cache, {{ PRODUCT_NAME }} will attempt to fulfill the request from a single global L2 cache POP in order to maximize your effective cache hit ratio. There is very little difference in time to first byte for responses served from the L1 vs L2 cache. In either case the response is served nearly instantly (typically 25-100ms). Concurrent requests for the same URL on different POPs that result in a cache miss will be coalesced at the L2 cache. This means that only one request at a time for each cacheable URL will reach your origin servers.
// Sets the TTL for a response in the XDN's edge cache
33
+
// Sets the TTL for a response in {{ PRODUCT_NAME }}'s edge cache
34
34
maxAgeSeconds:60*60*24,
35
35
36
-
// Sets the amount of time a stale response will be served from the cache. When a stale response is sent, the XDN
36
+
// Sets the amount of time a stale response will be served from the cache. When a stale response is sent, {{ PRODUCT_NAME }}
37
37
// will simultaneously fetch a new response to serve subsequent requests.
38
38
// Using stale-while-revalidate helps raise your effective cache hit rate to near 100%.
39
39
staleWhileRevalidateSeconds:60*60, // serve stale responses for up to 1 hour while fetching a new response
@@ -68,7 +68,7 @@ To ensure that your site is resilient to [cache poisoning attacks](security#sect
68
68
69
69
#### Customizing the Cache Key
70
70
71
-
It is often useful to customize the cache key, either to improve the cache hit ratio or to account for complexities of your site. As seen above, the XDN provides an easy way to customize the keys by using the `CustomCacheKey` class. Here we will focus on three common examples:
71
+
It is often useful to customize the cache key, either to improve the cache hit ratio or to account for complexities of your site. As seen above, {{ PRODUCT_NAME }} provides an easy way to customize the keys by using the `CustomCacheKey` class. Here we will focus on three common examples:
72
72
73
73
- Increasing the cache hit ratio by excluding query parameters that are not used in the rendering of the content:
74
74
@@ -168,7 +168,7 @@ Note that this feature cannot be safely used with caching of `POST` and similar
168
168
169
169
## Preventing a response from being cached
170
170
171
-
By default, the XDN will cache responses that satisfy all of the following conditions:
171
+
By default, {{ PRODUCT_NAME }} will cache responses that satisfy all of the following conditions:
172
172
173
173
1. The response must correspond to a `GET` or `HEAD` request. To override this see [POST and other non-GET/HEAD](#section_caching_responses_for_post_and_other_non_get_head_requests) section.
174
174
2. The response status must be 1xx, 2xx or 3xx. You cannot override this.
@@ -295,7 +295,7 @@ The cache can also be [cleared via the REST API](/guides/rest_api#section_clear_
295
295
296
296
## Static prerendering after clearing the cache
297
297
298
-
If you have [static prerendering] enabled, the cache will automatically be repopulated when you clear all entries from the cache (when you select "Purge all entries" in the XDN Developer Console or run `xdn cache-clear` without providing `--path` or `--surrogate-key`). You can view the prerendering progress by clicking on the active deployment for the environment that was cleared.
298
+
If you have [static prerendering] enabled, the cache will automatically be repopulated when you clear all entries from the cache (when you select "Purge all entries" in {{ PRODUCT_NAME }} Developer Console or run `xdn cache-clear` without providing `--path` or `--surrogate-key`). You can view the prerendering progress by clicking on the active deployment for the environment that was cleared.
299
299
300
300
## Preserving the cache when deploying a new version of your site
301
301
@@ -336,7 +336,7 @@ This guide walks you through clearing the cache on your site at a scheduled day
336
336
337
337
## NPM script
338
338
339
-
Here is an example script you can add to your `package.json` to handle cache clearing for each environment. You can also configure scripts to clear by surrogate key, path, or group (As defined in the XDN Console)
339
+
Here is an example script you can add to your `package.json` to handle cache clearing for each environment. You can also configure scripts to clear by surrogate key, path, or group (As defined in {{ PRODUCT_NAME }} Console)
340
340
341
341
These scripts assume that you have created environments called "production", "staging", and "development and you have created a deploy key for your site and added it as a secret in your repo called "xdn_deploy_token".
|`--skip-framework`| Alias: "-s". Skips the framework (Next.js, Vue, Angular, etc..) build and simply rebundles your router |
30
-
|`--disable-permanent-assets`| Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
31
-
|`--include-sources`| Includes all non-gitignored source files in the bundle uploaded to the XDN. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/xdn_config#section_sources) config in xdn.config.js. |
|`--skip-framework`| Alias: "-s". Skips the framework (Next.js, Vue, Angular, etc..) build and simply rebundles your router |
30
+
|`--disable-permanent-assets`| Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
31
+
|`--include-sources`| Includes all non-gitignored source files in the bundle uploaded to {{ PRODUCT_NAME }}. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/xdn_config#section_sources) config in xdn.config.js. |
32
32
33
33
#### Example
34
34
@@ -91,16 +91,16 @@ Builds and deploys your site on {{ PRODUCT_NAME }}.
|`--site`| The name of the site to deploy. By default the `name` field in `package.json` is used. |
97
-
|`--environment`| The environment to deploy to. By default the `default` environment is used. |
98
-
|`--branch`| The name of the source control branch. This is automatically set when using Git. |
99
-
|`--skip-build`| Skips the build step |
100
-
|`--token`| Authenticates using a deploy token rather than your user credentials. Use this option when deploying from CI. |
101
-
|`--commit-url`| The URL at which the commit can be viewed in your source control provided. If your package.json provides the repository attribute the commit URL will be derived automatically if you use GitHub, GitLab, or BitBucket. |
102
-
|`--include-sources`| Includes all non-gitignored source files in the bundle uploaded to the XDN. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/xdn_config#section_sources) config in xdn.config.js. |
103
-
|`--disable-permanent-assets`| Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
|`--site`| The name of the site to deploy. By default the `name` field in `package.json` is used. |
97
+
|`--environment`| The environment to deploy to. By default the `default` environment is used. |
98
+
|`--branch`| The name of the source control branch. This is automatically set when using Git. |
99
+
|`--skip-build`| Skips the build step |
100
+
|`--token`| Authenticates using a deploy token rather than your user credentials. Use this option when deploying from CI. |
101
+
|`--commit-url`| The URL at which the commit can be viewed in your source control provided. If your package.json provides the repository attribute the commit URL will be derived automatically if you use GitHub, GitLab, or BitBucket. |
102
+
|`--include-sources`| Includes all non-gitignored source files in the bundle uploaded to {{ PRODUCT_NAME }}. This can be helpful when debugging, especially when working with Moovweb support. You can limit the files that are uploaded using the [sources](/guides/xdn_config#section_sources) config in xdn.config.js. |
103
+
|`--disable-permanent-assets`| Set this to true to suppress errors like "Immutable file (...) content was changed" during deployment. |
Open the {{ PRODUCT_NAME }} documentation in your browser.
114
114
115
115
#### Example
116
116
@@ -120,7 +120,7 @@ xdn docs
120
120
121
121
### dev
122
122
123
-
Runs your project in development mode, simulating the XDN cloud environment. This command is a simplified version of `xdn run`, with only the --cache option being supported.
123
+
Runs your project in development mode, simulating the {{ PRODUCT_NAME }} cloud environment. This command is a simplified version of `xdn run`, with only the --cache option being supported.
124
124
125
125
#### Options
126
126
@@ -152,7 +152,7 @@ xdn init
152
152
153
153
### login
154
154
155
-
Logs into the XDN via the developer console.
155
+
Logs into {{ PRODUCT_NAME }} via the developer console.
156
156
157
157
#### Example
158
158
@@ -162,7 +162,7 @@ xdn login
162
162
163
163
### logout
164
164
165
-
Logs out of the XDN
165
+
Logs out of {{ PRODUCT_NAME }}
166
166
167
167
#### Example
168
168
@@ -187,7 +187,7 @@ Runs your app locally. Uses port 3000 by default. You can change this by setting
187
187
xdn run --production
188
188
```
189
189
190
-
Or to run a deployment bundle downloaded from the XDN Developer Console, use:
190
+
Or to run a deployment bundle downloaded from {{ PRODUCT_NAME }} Developer Console, use:
0 commit comments