Skip to content

Commit b9186df

Browse files
author
Jason Barry
committed
Adding more content to readme
1 parent 96941e3 commit b9186df

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

README.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,49 +167,47 @@ You can also configure both redirects and headers inside the `/netlify.toml` fil
167167

168168
<details><summary>Part 2: Rendering techniques and caching strategies</summary>
169169

170-
i. Purge cache of specific tags using an API call
171-
172-
```bash
173-
curl -X POST 'https://api.netlify.com/api/v1/purge' \
174-
-H 'Authorization: Bearer <token>' \
175-
-H 'Content-Type: application/json' \
176-
-d '{"site_id":"$SITE_ID","cache_tags":["books"]}'
177-
```
178-
179170
💡 Learn more about [caching](https://docs.netlify.com/platform/caching/) in our docs.
180171

181172
</details>
182173

183174
<details><summary>Part 3: Going serverless with Functions</summary>
184175

185-
```typescript
186-
export const config: Config = {
187-
method: "GET",
188-
path: "/api/books{/:id}?",
176+
**🧑‍💻 Relevant demo and code:**
177+
178+
- [Proxy to APIs](https://netlify-core-workshop.netlify.app/primitives/functions/proxy) ([netlify/functions/dad-joke.ts](https://github.com/netlify/netlify-workshop/blob/main/netlify/functions/dad-joke.ts))
179+
- [Combine and filter APIs](https://netlify-core-workshop.netlify.app/primitives/functions/combine-and-filter) ([netlify/functions/platform-specific.ts](https://github.com/netlify/netlify-workshop/blob/main/netlify/functions/platform-specific.ts))
180+
- [Streaming APIs](https://netlify-core-workshop.netlify.app/primitives/functions/streams) ([netlify/functions/stream.ts](https://github.com/netlify/netlify-workshop/blob/main/netlify/functions/stream.ts))
181+
182+
Serverless functions open a world of possibilities for running on-demand, server-side code without having to run a dedicated server.
183+
184+
With Netlify Functions, your serverless functions are version-controlled, built, and deployed along with the rest of your Netlify site, and we will automatically handle service discovery through our built-in API gateway. This eliminates overhead and brings the power of Deploy Previews and rollbacks to your functions.
185+
186+
By default, any JavaScript/TypeScript file in a site's `netlify/functions` directory will become a Function available at the `/.netlify/functions/{filename}` route. A simple Hello World would look like this:
187+
188+
```ts
189+
// netlify/functions/hello-world.js
190+
export default async () => {
191+
return new Response("Hello world!");
189192
};
190193
```
191194

192-
💡 The `path` parameter follows the [URL Pattern API](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) spec.
195+
Once deployed, you can visit `/.netlify/functions/hello-world` to invoke your Function in production.
193196

194197
💡 Learn more about [Functions](https://docs.netlify.com/functions/overview/) in our docs.
195198

196199
</details>
197200

198201
<details><summary>Part 4: Run middleware and personalize with Edge Functions</summary>
199202

200-
We're going to make a swag section of the site that is personalized to the user based on their geolocation. Edge functions act as middleware for the CDN &mdash; they run in front of other routes!
203+
**🧑‍💻 Relevant demo and code:**
201204

202-
i. Edge Functions are also great places to add A/B testing. You can add a cookie at the edge to segment user traffic into groups (also known as buckets) to run experimentation. Set a new cookie in `netlify/edge-functions/abtest.ts`:
205+
- [A/B testing](https://netlify-core-workshop.netlify.app/primitives/edge-functions/ab-testing) ([netlify/edge-functions/abtest.ts](https://github.com/netlify/netlify-workshop/blob/main/netlify/edge-functions/abtest.ts))
206+
- [Geolocation](https://netlify-core-workshop.netlify.app/primitives/edge-functions/geolocation) ([netlify/edge-functions/get-geo.ts](https://github.com/netlify/netlify-workshop/blob/main/netlify/edge-functions/get-geo.ts))
203207

204-
```diff
205-
+ // set the new "ab-test-bucket" cookie
206-
+ context.cookies.set({
207-
+ name: bucketName,
208-
+ value: newBucketValue,
209-
+ });
208+
Edge functions are like Functions, but they execute closer to where your users are. While you can reach them as you would an endpoint, they can also chain in front of any route on your site. Think of them like middleware for the CDN: they can add HTTP headers and transform responses, passing along the next request, before ultimately reaching your users.
210209

211-
return response;
212-
```
210+
All this dynamic processing happens in a secure runtime based on Deno directly from the worldwide network edge location closest to each user for fast response times. Plus, you have the option to cache edge function responses for even faster response times. Edge functions are version-controlled, built, and deployed along with the rest of your site. This eliminates overhead and brings the power of Deploy Previews and rollbacks to your edge functions.
213211

214212
💡 Learn more about [Edge Functions](https://docs.netlify.com/edge-functions/overview/) in our docs.
215213

0 commit comments

Comments
 (0)