You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow Users to Set Edge Cache TTL for Resources #4077
As a user, I want to override my CMS/API cache headers and allow Webstudio/Cloudflare to cache the response. This will improve performance and reduce API calls to my origin, potentially reducing the bill there.
I see further use case for this feature. I self host directus instances on cheap digital ocean and linode instances. Most of my content is evergreen blog content. I haven't run into issues yet but I would like a way to avoid having my API hit each time a page is requested. I assume that others out there may be self hosting directus, strapi and other headless systems and using them in a similar way.
@pausak API is only hit when cache is missed even today, but there is no guarantee it doesn't hit because:
cache can be lost/purged any time
visitor may be hitting an edge that was never visited before on that page, so cache is empty
API was sending bad headers and didn't allow for the response to be cached
So with this option we are taking care of 3 - which would fix potential issues with various API services + ignore what time to live they have defined and define your own, e.g. you know you don't care if the change on an article goes live in 2 hours - you can set it 2 hours or 2 days. We don't have to hit origin to just ask if the content is still up-to-date.
A quite different story is wanting to permanently store the responses in a R1/S3 type of storage and have a guaranteed availability for that content even if the backend goes down and TTL expires.
This is quite different because that would mean we would be storing a lot of data. Quite interesting though still to investigate how demanded this would be.
I think this will require additional thinking around: oberving what's in the store, manually clearing things etc. It would have to also go into total storage limit calculation on pricing.
Additionally it would have to store any media content as well, if we wanted to achieve full reliability with a backend being down.
Activity
johnsicili commentedon Nov 10, 2024
Elevating to P1 because services like Baserow and Airtable just implemented 1,000 calls per month limits.
IIRC, this should be relatively simple to implement. If complexity is high, we can put it back to a P2.
kof commentedon Nov 10, 2024
Sounds like a big deal in terms of cost in general as well, its worth making a standalone micro-launch just for this feature alone.
pausak commentedon Dec 19, 2024
I see further use case for this feature. I self host directus instances on cheap digital ocean and linode instances. Most of my content is evergreen blog content. I haven't run into issues yet but I would like a way to avoid having my API hit each time a page is requested. I assume that others out there may be self hosting directus, strapi and other headless systems and using them in a similar way.
kof commentedon Dec 19, 2024
@pausak API is only hit when cache is missed even today, but there is no guarantee it doesn't hit because:
So with this option we are taking care of 3 - which would fix potential issues with various API services + ignore what time to live they have defined and define your own, e.g. you know you don't care if the change on an article goes live in 2 hours - you can set it 2 hours or 2 days. We don't have to hit origin to just ask if the content is still up-to-date.
kof commentedon Dec 19, 2024
A quite different story is wanting to permanently store the responses in a R1/S3 type of storage and have a guaranteed availability for that content even if the backend goes down and TTL expires.
This is quite different because that would mean we would be storing a lot of data. Quite interesting though still to investigate how demanded this would be.
I think this will require additional thinking around: oberving what's in the store, manually clearing things etc. It would have to also go into total storage limit calculation on pricing.
Additionally it would have to store any media content as well, if we wanted to achieve full reliability with a backend being down.
aleksb3 commentedon Dec 19, 2024
At least when it comes to directus the following project looks interesting and may tie in well:
https://github.com/licitdev/directus-cf-cache
Allows you to serve data from cloudflare kv cache as a fallback if your API is unavailable.
kof commentedon Dec 19, 2024
generally good, I wish the code wasn't looking this fragile with all that custom logic on top of their api. I wouldn't trust it to run well over time https://github.com/licitdev/directus-cf-cache/blob/master/workers/directus-cf-cache-worker/api.ts
There must be something more generic than this.
pausak commentedon Dec 19, 2024
Was thinking the same, but haven’t come across anything yet.
feat: cache resources (#5381)
TrySound commentedon Sep 7, 2025
Released