Solved! Cron job will only work after clearing the cache

I have multiple cron jobs that are access via CURL files.

Curl -> Cron Job

The cron job works but will only work once. If I test it a second time immediately, nothing happens. I will clear the cache from my hosting (the dynamic cache on Site Ground) and then it will work again, but only once.

On my local host, no problems. Why is it doing this while on the hosting site?

Edit: Siteground has built in caching heaaers that I can put at the top of the page:

header("Cache-Control: no-cache");

Answer

I know it’s not easy to deal with SiteGround SuperCacher that can be annoying since you can’t exclude it by specific path. Anyway you still have a couple of chances:

1) Add a fake param with a timestamp to your query string:

curl --request GET https://www.youtdomain.com/yourpath?v=`(date +"%s")`

Test response headers adding -I and look for “x-proxy-cache: MISS” before put it in your crontab

2) Configure your script to return nocache header If you have access to the remote script on SiteGround, add this response header to tell SG proxy not to cache that resource:

<?php
    header( 'Cache-Control: max-age=0,no-store');
?>