Skip to content

Allow Users to Set Edge Cache TTL for Resources #4077

Closed

Description

@johnsicili

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.

Cloudflare offers this ability with cacheTtl: https://developers.cloudflare.com/workers/runtime-apis/request/#the-cf-property-requestinitcfproperties

Briefly discussed with Ivan in DM; creating an issue so I can link to it.

Activity

  1. added
    area:settingsSettings panel on the right
    type:featFeatures and enhancements
    prio:2Always look for prio:1 issues first before working on prio:2
    on Sep 6, 2024
  2. added
    prio:1The most important thing to work on
    and removed
    prio:2Always look for prio:1 issues first before working on prio:2
    on Nov 10, 2024
  3. johnsicili commented on Nov 10, 2024

    @johnsicili
    ContributorAuthor

    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.

  4. kof commented on Nov 10, 2024

    @kof
    Member

    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.

  5. pausak commented on Dec 19, 2024

    @pausak

    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.

  6. kof commented on Dec 19, 2024

    @kof
    Member

    @pausak API is only hit when cache is missed even today, but there is no guarantee it doesn't hit because:

    1. cache can be lost/purged any time
    2. visitor may be hitting an edge that was never visited before on that page, so cache is empty
    3. 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.

  7. kof commented on Dec 19, 2024

    @kof
    Member

    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.

  8. aleksb3 commented on Dec 19, 2024

    @aleksb3

    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.

  9. kof commented on Dec 19, 2024

    @kof
    Member

    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.

    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.

  10. pausak commented on Dec 19, 2024

    @pausak

    Was thinking the same, but haven’t come across anything yet.

  11. added a commit that references this issue on Aug 25, 2025
  12. TrySound commented on Sep 7, 2025

    @TrySound
    Contributor

    Released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:settingsSettings panel on the rightprio:1The most important thing to work ontype:featFeatures and enhancements

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions