google / sxg-rs

A set of tools for generating signed exchanges at serve time.
Apache License 2.0
83 stars 20 forks source link

Add Vercel binding #272

Open twifkak opened 2 years ago

twifkak commented 2 years ago

There are two three types of Vercel Functions and I'm not sure of the compare/contrast. One comparison here. There is a community Rust binding (API).

For storage, one can connect to an external DB but perhaps a more config-free approach would be to use edge caching and set up internal HTTP APIs for certs/OCSP.

twifkak commented 2 years ago

OK, Vercel doesn't support custom cache keys, which we need to separate SXG responses (for SXG crawlers) from non-SXG (for browsers and non-SXG crawlers). Judging by this flow diagram we should target Edge Middleware which isn't cached, so that users can still enable caching behind it.

twifkak commented 2 years ago

Perhaps the simplest option is to support some external DB with a free tier.

To clarify the "use edge caching and set up internal HTTP APIs" idea: Request the outcome of the last step. The handler for each step recursively fetches the previous step, and sets long cache headers for successful outcomes.

serve_preset_content would be handled by Vercel Functions, not Middleware, so it could be cached. When handling requests for the following URLs:

(We may also want to sign these URLs so external requestors can't forge them.)