TOPIC: Delete All cache cron

Delete All cache cron 19 Jun 2017 11:29 #1969

Hi,

PHP CURL functions are disabled on my server for security reasons. Here is what I want to achieve through CLI for rebuilding the cache.
Schedule a cron job to delete all cache.
Crawl the website using wget or something else to build the cache.

Could you please guide me on how to Delete All cache through PHP CLI?

Thanks

Joomla version : 3.7
JotCache version : 5.2.1
site template:
system plugins :
The administrator has disabled public write access.

Delete All cache cron 20 Jun 2017 08:38 #1972

For delete ALL cache with PHP CLI command you can use modified JotCache cron job file in /administrator/components/com_jotcache/cron/cron.php. Here is needed to delete all content of page cache in file system as well as in database table '#_jotcache'. One possible solution consist from 2 steps:

1. insert after line 30 (require_once JPATH_BASE . '/includes/framework.php';) following code:
function rrmdir($dir) {
  if (is_dir($dir)) {
    $objects = scan_dir($dir);
    foreach ($objects as $object) {
      if ($object != "." && $object != "..") {
        if (filetype($dir."/".$object) == "dir") 
           rrmdir($dir."/".$object); 
        else unlink   ($dir."/".$object);
      }
    }
    reset($objects);
    rmdir($dir);
  }
}
NOTE!! Remove in your code character '_' in scan_dir

2. insert after original line 45 ($root = JPATH_BASE . DS . 'cache' . DS . 'page';) folowing code:
rrmdir($root);

Then run patched cron.php inside of server cron job.
The administrator has disabled public write access.

Delete All cache cron 20 Jun 2017 11:40 #1973

That worked perfectly. Just had to update the JPATH_BASE on line 24.

I however am not able to build the cache. I have a script that requests all the URLs in the sitemap using CURL. I can see the requests with status 200 in the log files, but can't see it being cached in JotCache.

I have also tried using javascript from the browser. I use jquery ajax to request all the links from sitemap. I can see all the pages loaded correctly in the console. But no cache built in JotCache.

I am not sure why it doesn't build the cache when URLs are requested through scripts. Is speed at which they are requested an issue?

Many thanks for the help.


Joomla version : 3.7
JotCache version :
site template:
system plugins :
The administrator has disabled public write access.

Delete All cache cron 20 Jun 2017 14:52 #1974

All ajax requests are excluded from caching by design. For detailed analysis what happens on your site during JotCache activity you can install JotCache ver.6.0.2 which has new feature - caching debug (more about this feature you can find in JotCache Help and some topics on this forum).
The administrator has disabled public write access.

Delete All cache cron 20 Jun 2017 15:24 #1976

As per your advise, I have installed latest version and this is what I see in the log for all the ajax requests:
immediate exit on [XMLHttpRequest...

For non-ajax requests, it works fine:
current browser in common group [Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393]
2017-06-20 13:15:57 READ CACHE start [...]
2017-06-20 13:15:57 READ CACHE after exclude check
2017-06-20 13:15:57 READ CACHE no data
2017-06-20 13:15:57 WRITE CACHE start
2017-06-20 13:15:57 WRITE CACHE after save in storage [true]
2017-06-20 13:15:57 WRITE CACHE stored data [b8ebea87e1ca071f3f40d6d7426d7558]
The administrator has disabled public write access.

Delete All cache cron 20 Jun 2017 15:28 #1978

Yes - it is OK. It is normal operation.
The administrator has disabled public write access.

Delete All cache cron 20 Jun 2017 15:41 #1979

However, it is not building the cache for ajax requests.

In case of curl requests, I see the issue being: "current browser excluded". Can I add my custom user-agent to whitelist? or should I try with some other browser string?

Thanks
The administrator has disabled public write access.

Delete All cache cron 25 Jun 2017 10:37 #1983

All ajax requests are excluded from caching by design.
Ajax calls in JotCache are automatically excluded from caching.

Use for curl requests user-agent string exactly as Google bot is using.
The administrator has disabled public write access.
Time to create page: 0.246 seconds
We have 48 guests and no members online
Copyright © 2015 JotComponents
We have 48 guests and no members online
Copyright © 2017 JotComponents