splitbee / notion-api-worker

Notion as CMS with easy API access
MIT License
1.55k stars 198 forks source link

Proposal: Add default cache-control #22

Open transitive-bullshit opened 4 years ago

transitive-bullshit commented 4 years ago

cache.put(request, response) uses the response's cache-control header to determine the object's TTL (and other standard headers).

Currently, we're passing responses with no cache-control which isn't really well-specified by Cloudflare as to what this actually means.

Experimentally, it appears that CF caches these objects for ~10 seconds, but we should really override this with a default value.

Note that for Notion2Site, I'm passing pragma: no-cache to disable caching within the worker because Vercel's SWR edge caching is all that's needed. Any additional caching of the page data just introduces additional lag before updates are reflected to their edge cache.

Syntyche3456 commented 2 years ago

Friend