Step by Step Guide - Purge Files by URL

Hi all,

I’ve searched and read the articles Cloudflare API v4 Documentation but I’m really not clear on how to do this.

I have 3 pages on my website that need to have the cache cleared at certain times.

Page 1 and Page 2 at 9.45am
Page 1 and Page 3 at 8.15pm

I assume that I need to run a cron for these times but I’m not sure what I should be calling.

Should I be creating a file to be called? If so what should I put in the file and where should I store it, I obviously don’t want sensitive information in the public domain.

I’m not a coder so please be patient with me on this - a simple step by step in non technical terms would be great :see_no_evil:

PS - I know I can log in and clear the pages manually but I’d rather not have to remember!

Does this mean you’ve added a Cache Everything page rule, or have something similar in place?

Then the API isn’t really a suitable option.

I think I’m going to double down on my statement, as the API is a technical endeavor.

But here’s the breakdown: You’ll need two scripts. Let’s call them 945a and 815p. Each one has an API call for each URL you want purged. And then set up cronjobs on your server to run them.

curl -X POST "" \
     -H "X-Auth-Key: YOUR_GLOBAL_API_KEY" \
     -H "Content-Type: application/json" \
     --data '{"files":[""]}'

You’ll need to save these scripts in a secure directory on your server and be aware that if it’s not your own personal server, security of the Global API Key isn’t guaranteed.

Thanks for the swift response, this kind of makes sense. 2 follow up questions.

I’m saving as 2 scripts one for each purge. I just paste into new file but what should the file extension be?

–data ‘{“files”:[“”]}’ - how do I list the multiple urls?

–data ‘{“files”:[“"],["”]}’ would this be correct?

For scripts, I usually use a .sh extension. It really doesn’t matter that much.

–data ‘{“files”:[“","”]}’ would this be correct?

Try getting rid of the brackets between the two URLs. I believe it should be a comma separated list.

This topic was automatically closed after 31 days. New replies are no longer allowed.