-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
Datasette should serve Access-Control-Max-Age #2079
Comments
Also need to update this documentation: Lines 453 to 465 in 9584879
Or maybe make that automated via |
I'm going with 3600 for 1 hour instead of 600 for 10 minutes. |
I ran this on https://www.example.com/ twice using the console: fetch(
`https://latest.datasette.io/ephemeral/foo/1/-/update`,
{
method: "POST",
mode: "cors",
headers: {
Authorization: `Bearer tok`,
"Content-Type": "application/json",
},
body: JSON.stringify({update: {blah: 1}}),
}
)
.then((r) => r.json())
.then((data) => {
console.log(data);
}); And got this in the network pane: |
https://fetch.spec.whatwg.org/#http-access-control-max-age says:
So there was already a 5s cache anyway. |
Wrote this up as a TIL: https://til.simonwillison.net/http/testing-cors-max-age |
Currently the CORS headers served are:
datasette/datasette/utils/__init__.py
Lines 1139 to 1143 in 9584879
Serving
Access-Control-Max-Age: 600
would allow browsers to cache that for 10 minutes, avoiding additional CORS pre-flight OPTIONS requests during that time.The text was updated successfully, but these errors were encountered: