Skip to content

[Workers] tutorials style guide revision #3199

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

Merged
merged 13 commits into from
Jan 21, 2022

Conversation

deadlypants1973
Copy link
Contributor

No description provided.

@deadlypants1973 deadlypants1973 added this to the Pages and Workers milestone Jan 20, 2022
@deadlypants1973 deadlypants1973 self-assigned this Jan 20, 2022
@deadlypants1973 deadlypants1973 requested review from a team as code owners January 20, 2022 15:18
@@ -166,7 +166,7 @@ To cache responses in a Workers function, the Cache API provides `cache.match`,
2. If `response` does not exist, get the asset from cloud storage, set it to `response`, and cache it.
3. Return `response` from the function, back to the `fetch` event handler.

The `Cache-Control` header is a common way that HTML responses indicate how they should be cached. The Workers implementation respects the `Cache-Control` header, in indicating how assets should be cached on Cloudflare’s CDN. In building a custom asset serving solution, and enabling caching, you should set a custom `Cache-Control` header (in this example, we’ll set it to `public`, and a `max-age` value of `14400` seconds, or four hours).
The `Cache-Control` header is a common way that HTML responses indicate how they should be cached. The Workers implementation respects the `Cache-Control` header, in indicating how assets should be cached on Cloudflare’s CDN. In building a custom asset serving solution, and enabling caching, you should set a custom `Cache-Control` header (in this example, you will set it to `public`, and a `max-age` value of `14400` seconds, or four hours).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `Cache-Control` header is a common way that HTML responses indicate how they should be cached. The Workers implementation respects the `Cache-Control` header, in indicating how assets should be cached on Cloudflare’s CDN. In building a custom asset serving solution, and enabling caching, you should set a custom `Cache-Control` header (in this example, you will set it to `public`, and a `max-age` value of `14400` seconds, or four hours).
The `Cache-Control` header is a common way that HTML responses indicate how they should be cached. The Workers implementation respects the `Cache-Control` header, in indicating how assets should be cached on Cloudflare’s CDN. In building a custom asset serving solution, and enabling caching, you should set a custom `Cache-Control` header (in this example, you will set it to `public` and a `max-age` value of `14400` seconds, or four hours).


1. Update the `handleEvent` function to make a request to your origin.

While you are currently using Workers Sites, you can update `workers-site/index.js` and replace the Workers Site code with a request to your origin:
While you are currently using Workers Sites, update `workers-site/index.js` and replace the Workers Site code with a request to your origin:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This content belongs to step 1 but it is not indented below it. Consider making these steps two sub-sections, since the text is quite long.

@@ -946,7 +948,7 @@ Following this example, the callback URL for my application is `https://my-auth-

In order to safely store user IDs (the sub value from Auth0) in the cookie we set in the browser, you should always refer to them by a value that cannot be easily guessed by someone else. To do this, generate a unique value based on the user’s ID and a salt: a secret value provided by the application.

To generate a salt, make a new, random string, and save it as a secret for our application. Previously, this tutorial used `csprng.xyz` API to generate a random piece of `state` to protect against CSRF attacks. Open `https://csprng.xyz/v1/api` in your browser, and copy the `Data` field to your clipboard. If you would like to generate a string yourself, remember that it is important that the salt cannot easily be guessed.
To generate a salt: make a new, random string, and save it as a secret for our application. Previously, this tutorial used `csprng.xyz` API to generate a random piece of `state` to protect against CSRF attacks. Open `https://csprng.xyz/v1/api` in your browser, and copy the `Data` field to your clipboard. If you would like to generate a string yourself, remember that it is important that the salt cannot easily be guessed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To generate a salt: make a new, random string, and save it as a secret for our application. Previously, this tutorial used `csprng.xyz` API to generate a random piece of `state` to protect against CSRF attacks. Open `https://csprng.xyz/v1/api` in your browser, and copy the `Data` field to your clipboard. If you would like to generate a string yourself, remember that it is important that the salt cannot easily be guessed.
To generate a salt: make a new, random string, and save it as a secret for your application. Previously, this tutorial used `csprng.xyz` API to generate a random piece of `state` to protect against CSRF attacks. Open `https://csprng.xyz/v1/api` in your browser, and copy the value of the `Data` field to the clipboard. If you would like to generate a string yourself, remember that it is important that the salt cannot easily be guessed.

deadlypants1973 and others added 3 commits January 21, 2022 11:26
Pedro's suggestions

Co-authored-by: Pedro Sousa <[email protected]>
Co-authored-by: Luke Edwards <[email protected]>
Co-authored-by: Pedro Sousa <[email protected]>
Co-authored-by: Luke Edwards <[email protected]>
@deadlypants1973 deadlypants1973 merged commit 706f346 into production Jan 21, 2022
@deadlypants1973 deadlypants1973 deleted the kate/workersfixestwo branch January 21, 2022 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants