THERE IS A WAY - however it needs root modifications to each underlying server. Read on.
"There is not currently any user accessible API that exposes the current state of NGINX caching.
I did some research into how the cPanel UI obtains the status and I found that it just reads the root owned file directly:
/usr/local/cpanel/base/frontend/jupiter/tools/index.tt: SET nginx_caching_global = JSON.loadfile("/etc/nginx/ea-nginx/cache.json");
/usr/local/cpanel/base/frontend/jupiter/tools/index.tt: IF nginx_caching_global.exists("enabled");
This isn't something that you'd be able to do as the cPanel user though.
You'd need to submit a feature request to add this as a user accessible data point.
In the meantime I came up with a workaround for you that you can implement with the following steps:
Login to the server via SSH as the root user
Create the following file:
touch /usr/local/cpanel/3rdparty/bin/nginxCacheEnableUpdate.sh
Now after you toggle the NGINX cache status from the sidebar in cPanel the following file will contain the cache status in boolean format. 1 for enabled, 0 for disabled. If your plugin makes use of the UAPI to enable and disable the NGINX cache, your plugin will also update this file.
We typically do not provide code examples, but I'm personally familiar with this topic and I figured I could potentially save you quite a bit of time and research effort if I were to do some review and testing to verify that my idea would work."
THERE IS A WAY - however it needs root modifications to each underlying server. Read on.
"There is not currently any user accessible API that exposes the current state of NGINX caching.
I did some research into how the cPanel UI obtains the status and I found that it just reads the root owned file directly:
This isn't something that you'd be able to do as the cPanel user though.
You'd need to submit a feature request to add this as a user accessible data point.
In the meantime I came up with a workaround for you that you can implement with the following steps:
touch /usr/local/cpanel/3rdparty/bin/nginxCacheEnableUpdate.sh
chmod 0755 /usr/local/cpanel/3rdparty/bin/nginxCacheEnableUpdate.sh
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/nginxCacheEnableUpdate.sh --manual --category Cpanel --event UAPI::NginxCaching::enable_cache --stage=post
touch /usr/local/cpanel/3rdparty/bin/nginxCacheDisableUpdate.sh
chmod 0755 /usr/local/cpanel/3rdparty/bin/nginxCacheDisableUpdate.sh
/usr/local/cpanel/bin/manage_hooks add script /usr/local/cpanel/3rdparty/bin/nginxCacheDisableUpdate.sh --manual --category Cpanel --event UAPI::NginxCaching::disable_cache --stage=post
Now after you toggle the NGINX cache status from the sidebar in cPanel the following file will contain the cache status in boolean format. 1 for enabled, 0 for disabled. If your plugin makes use of the UAPI to enable and disable the NGINX cache, your plugin will also update this file.
This file is owned by the cPanel user so it would be accessible to your plugin file to read directly.
I referenced the following resources to put this together:
We typically do not provide code examples, but I'm personally familiar with this topic and I figured I could potentially save you quite a bit of time and research effort if I were to do some review and testing to verify that my idea would work."