Their are times where you need apc.php to clear browser cache, either you can write a code to clear the cache or to view cache contents via browser.

you can just protect it via HTTP AUTH to avoid being viewed by third-party

Here we are using Nginx as Front-end and PHP_fpm as back-end,

Considering apc has already been installed,

locate apc.php file on server and copy it to desired location,

Consider a Scenario, abc.com.au has apc.php inside public_html/cache/apc.php

Below is the Nginx code to protect apc.php file, below should be under v-hosts file of a domain abc.com.au,

location ^~ /cache {
auth_basic “Admin”;
auth_basic_user_file /var/www/html/htpasswd;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}

  • htpasswd -b -c /var/www/html/htpasswd test1 g009fdr

where, test1 : username and g009fdr: password

  • rename apc.php to index.php
  • vi index.php and make changes as shown below,

apc

  • service nginx restart