Skip to content
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

thomasgauvin: First draft at KV tutorial to serve static & dynamic re… #15495

Open
wants to merge 3 commits into
base: production
Choose a base branch
from

Conversation

thomasgauvin
Copy link
Contributor

…sponses from KV assets

Copy link

cloudflare-pages bot commented Jul 6, 2024

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2eb06a3
Status: ✅  Deploy successful!
Preview URL: https://cda6a150.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://thomasgauvin-kv-tutorials-pa.cloudflare-docs-7ou.pages.dev

View logs

@Cherry
Copy link
Contributor

Cherry commented Jul 7, 2024

Love this use-case of KV, but this is essentially Workers Sites, right?
But handling the assets very manually, without the nice kv-asset-handler wrapper?

https://developers.cloudflare.com/workers/configuration/sites/

Is this something intended for folks to still be doing? What about Cloudflare Pages? Or the --assets binding within wrangler?

@thomasgauvin
Copy link
Contributor Author

thomasgauvin commented Jul 8, 2024

Love this use-case of KV, but this is essentially Workers Sites, right? But handling the assets very manually, without the nice kv-asset-handler wrapper?

https://developers.cloudflare.com/workers/configuration/sites/

Is this something intended for folks to still be doing? What about Cloudflare Pages? Or the --assets binding within wrangler?

@Cherry, yep, this is essentially Workers Sites (some of the code in here is taken from Workers Sites & KV assets handler code). The intention is to show how KV can be used (without the KV assets handler abstraction) directly. It serves as a tutorial for a common use of KV to make it more easily discoverable from KV docs.

There is a call-out at the top of https://e37d08d7.cloudflare-docs-7ou.pages.dev/kv/tutorials/workers-kv-to-serve-assets/ that indicates that Pages is the platform to use for serving assets of web applications.

This tutorial demonstrates how to access data and assets from KV and use them to generate static and dynamic responses. If you want to serve static assets of a frontend web application, consider using [Cloudflare Pages](https://e37d08d7.cloudflare-docs-7ou.pages.dev/pages/) which provides a purpose-built experience for web applications with built-in environments, CI/CD integration and more.

I'll make sure to align with the roadmap for Workers Sites. It was also my intent to include https://github.com/cloudflare/workers-sdk/tree/85a22faa75c9d33e7790aa78e49e5c18982a179f/packages/kv-asset-handler as well, I'm just checking on that package's roadmap as well to make sure we have the right framing.

@isaac-mcfadyen
Copy link
Contributor

[...] how to access data and assets from KV and use them to generate static and dynamic responses. If you want to serve static assets of a frontend web application, consider using Cloudflare Pages [...]

Wondering if we want to call out dynamic content with Pages too? Pages isn't just static content, you can also serve dynamic content with Functions (and without needing to use a manual KV implementation).

@thomasgauvin
Copy link
Contributor Author

thomasgauvin commented Jul 8, 2024

Considering that Workers Sites docs indicate 'Do not use Workers Sites for new projects.', I'm inclined to leave the PR as is (not including a mention of Workers Sites or kv-assets-handler).

I will edit the Pages guidance to include the fact that it supports dynamic responses, but given folks land here for 'serving static assets for KV', I think the guidance from here to Pages for serving static assets for a web application is appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants