Nginx cache disable for PHP and Curl

I have time problem on Ubuntu 20.04 - and I think this cause by nginx cache,

When I command time : timedatectl System clock synchronized: yes,

but when I request time in PHP via curl the time not being change,
https://domain.com/time.php

but If I add some rnd parameter in same URL time get update every seconds.
https://domain.com/time.php?action=time&rnd=$rnd

server {
listen 0.0.0.0:443 ssl http2;
server_name domain.com www.domain.com;
ssl_certificate /home/admin/conf/web/domain.com/ssl/domain.com.pem;
ssl_certificate_key /home/admin/conf/web/domain.com/ssl/domain.com.key;
ssl_stapling on;
ssl_stapling_verify on;
error_log /var/log/apache2/domains/domain.com.error.log error;

include /home/admin/conf/web/domain.com/nginx.hsts.conf*;

# protect videos from direct access
location ^~ /contents/videos/ {
    root /home/admin/web/domain.com/public_html;
    limit_rate_after 2m;
    expires        35d;
    internal;
}

location ^~ /contents/albums/ {
    root /home/admin/web/domain.com/public_html;
    expires        35d;
}

location / {
    proxy_pass      https://0.0.0.0:8443;

    proxy_cache cache;
    proxy_cache_valid 15m;
    proxy_cache_valid 404 1m;
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    proxy_cache_bypass $cookie_session $http_x_update;

    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|g>
        proxy_cache    off;
        root           /home/admin/web/domain.com/public_html;
        access_log     /var/log/apache2/domains/domain.com.log combined;
        access_log     /var/log/apache2/domains/domain.com.bytes bytes;
        expires        35d;
        try_files      $uri @fallback;
    }
}

Adding a random parameter is the easiest method to do it… Or you could add an exception for time.php

time.php is just a test file, I have many php curl request file, so I want fix it for globally on the server

Thanks

If you use the curl request via cronjob check out how the same command via cli / /usr/bin/php as it solve many issues with caching but also the timeouts you might have.

Maybe check if you can create an exception on the cache for proxy cache. Otheriwise the random number / parameter is the easiest option

If you use the curl request via cronjob

Yes I use the curl request via cronjobs

Can you please give me more example for details for:

check out how the same command via cli / /usr/bin/php as it solve many issues with caching but also the timeouts you might have.

and

Maybe check if you can create an exception on the cache for proxy cache.

/usr/bin/php /home/xxxx/web/xxxxx/public_html/wp-content/plugins/screenshot-video/cronjob.php >/dev/null 2>&1

This cronjob takes about 5 / 10 min (Depending if an Video need to to be processed or not)

You could also use parameters:
/usr/bin/php /home/xxxx/web/xxxxx/public_html/wp-content/plugins/screenshot-video/cronjob.php xxx yyyy zzz

These are availble via the $args variable.
https://zetcode.com/lang/php/basics/

Maybe check if you can create an exception on the cache for proxy cache

Google never tried it before.

I have try in CLI: php /home/admin/web/domain.com/public_html/time.php

not update time, always show the same time.

And I have same cronjob as you said;

Can you please tell me how I can disable nginx cache for .php /etc/nginx/nginx.conf

php /home/admin/web/domain.com/public_html/time.php doesn’t go trough nginx so it should never been cached.

root@dev:/home/admin/web/xxxx/public_html# php time.php
1621089922

root@dev:/home/admin/web/xxxx/public_html# php time.php
1621089923

root@dev:/home/admin/web/xxxx/public_html# 
root@dev:/home/admin/web/xxxx/public_html# php time.php
1621089924
root@dev:/home/admin/web/xxxx/public_html# php time.php
1621089924

root@dev:/home/admin/web/xxxx/public_html# php time.php
1621089925

root@dev:/home/admin/web/xxxx/public_html# php time.php
1621089925

The only thing can happen if you send out 2 request in at the same time it will return the same time…

I see this setting in /etc/nginx/nginx.conf

Can I disable here??

# Cache bypass
map $http_cookie $no_cache {
    default 0;
    ~SESS 1;
    ~wordpress_logged_in 1;
}

I try this way, but still caching for 8 minute

map $http_cookie $no_cache {
    default 0;
    ~SESS 1;
    ~wordpress_logged_in 1;
     ~*.php 1;
}