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

Friendlier cached GET API #55

Closed
mildbyte opened this issue Aug 17, 2022 · 2 comments · Fixed by #402
Closed

Friendlier cached GET API #55

mildbyte opened this issue Aug 17, 2022 · 2 comments · Fixed by #402

Comments

@mildbyte
Copy link
Contributor

If the GET API receives an unhashed SQL query in the URL (e.g. just urlencoded), hash it and redirect the user to the hashed endpoint), as per #20 (comment)

Need to consider the fact that the redirect will only make sense if the client ends up sending the actual query in the GET body/header correctly. So we need to use a redirect that preserves the headers/body and the client needs to send the headers/body in the original request as well, potentially limiting the friendliness of this.

@tv42
Copy link

tv42 commented Feb 17, 2023

I've had good success with putting urlencoded JSON in a GET query argument. Simplest possible thing and works just right with caching. There's a size limit, but that's not really different from headers.

At least for Cloudflare, limits seem pretty much equal: 16 KB for url, 16 KB for a single header. https://developers.cloudflare.com/workers/platform/limits/#request-limits

@mildbyte
Copy link
Contributor Author

mildbyte commented Mar 15, 2023

Using just the URL for the query definitely sounds feasible in this case (when we were designing Seafowl first, we were worried about URL limits and inconsistent stories about what query length fetch() and intermediate caches/proxies can accept).

Though we just discovered in #306 that Cloudflare will not cache CORS OPTIONS preflights, which is suboptimal for Seafowl instances that are supposed to scale to zero when idle. Even if a query result is cached by Cloudflare, a brand new browser visiting the page will still trigger a CORS preflight, waking up the instance and defeating the purpose of scaling to zero.

I think with using just the URL for the query we can make Seafowl requests be considered "simple" so that browsers won's send a CORS preflight altogether.

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 a pull request may close this issue.

2 participants