Cache JSON files for less than a minute on Edge Cache in Pro Plan

Hey fellow developers,

I would like to cache all my json files on the edge cache for about 10 seconds. They are updated on the origin by a php script about every two minutes. My current Cloudflare Plan is Pro and if i understand correctly my minimal TTL for Edge Cache when using Rules is one hour. So rules are no option for this…

So my question: Could i use Cloudflare workers to cache my json resources for 10 seconds even though i am at the Prop Plan? Or is the TTL on the workers also limited by my plan? I saw this stackoverflow answer that seems like exactly what i need.

That sounds an awful lot like this thread:

1 Like

Not far of. I actually read that thread too while researching.

But could this also be done with workers and for example the code from the stackoverflow answer i posted? Purging the cache seems like it is harder to do than just writing a worker. And sounds a lot scarier and dangerous to do. Maybe i am wrong because i am pretty new to Cloudflare :slight_smile: But it’s extremly important that the data my users are getting is not outdated!

I agree with the theory at the end of that thread. You can’t set a TTL lower than your plan allows.

That’s why the thread I linked to seemed like a better idea.

If nobody can confirm a Worker’s ability to go under the minimum TTL, you’ll have to test this yourself, which shouldn’t be too difficult.

Just did implement it by manually calling the API to purge the cache from my PHP script that is also generating the data. Works like expected :slight_smile: I should have been less worried. Thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.