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

Design Specs #1

Open
morenol opened this issue Apr 29, 2021 · 3 comments
Open

Design Specs #1

morenol opened this issue Apr 29, 2021 · 3 comments

Comments

@morenol
Copy link

morenol commented Apr 29, 2021

I am opening this issue to discuss about the desing of this project.

The main goal is to create a cloudflare worker that can be used as "proxy" for other sites. It should cache the page using the native KV of Cloudflare, maybe we can use a header to disable the cache or add a configuration to cache only certain kind of requests (maybe using regex or something more simple than that).

@morenol
Copy link
Author

morenol commented Apr 29, 2021

We have to check how cloudflare workers work, because I am not sure if we can use environment variables to define the configurations if that is not possible probably we need to look for something different. Does it exist compile time configurations?

I mean in order to define which paths are cached or which is the site that is going to be cached.

@EstebanBorai
Copy link
Member

Thanks for kick in @morenol!

Environment Variables

In relation to environment variables, on Cloudflare Workers you can specify variables via the wrangler.toml file. Refer to the documentation for more details.

I'm not 100% sure if this environment variables are available in the WASM context as well, but I'm pretty sure we can access them straight from this file:

https://github.com/rust-lang-ve/website-worker/blob/main/worker/worker.js

Key/Value Storage

In order to consume Cloudflare's Key/Value storage, I think we can give a try on cloudflare-rs crate (Which is a Work In Progress, at the moment of this writing).

cloudflare-rs

About Disabling Cache

Part of the main goal is to avoid hitting request limits, by providing this functionality:

maybe we can use a header to disable the cache or add a configuration to cache only certain kind of requests (maybe using regex or something more simple than that)

We would introduce a vulnerability for our logic, I would be agnostic about this and rely on Cache directly for this instead of relying on the consumer for this.

@morenol
Copy link
Author

morenol commented Apr 30, 2021

We would introduce a vulnerability for our logic, I would be agnostic about this and rely on Cache directly for this instead of relying on the consumer for this.

You are right, someone with bad intentions could hit our requests limits :(.

But in any case we need to find a way to purge the data in the KV workers. Edit: That can be done with the wrangler CLI: https://developers.cloudflare.com/workers/cli-wrangler/commands#kvkey

In relation to environment variables, on Cloudflare Workers you can specify variables via the wrangler.toml file. Refer to the documentation for more details.

That sounds fine, I already saw that you already added in scripts/make-wrangler.sh all the things needed to create that file with environment variables, so that's nice!

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

No branches or pull requests

2 participants