Jump to content

Use Developer Events to delete cache


Daniel.de

Recommended Posts

Hi Everybody,

I am planning to use Joomlas Page Cache Plugin or Speedcache. After someone creates or update a listing, we have to wait until the cache is cleared. For Admins, it's easy to clear the cache in the backend, but for public or registreds users it's not. So I am trying to delete the cache after a listing was updated or changed.

First I tried Regular Labs "Cache Cleaner". Cache Cleaner can also clear Joomla! cache automatically when you save (or apply) an article or other item. You can also enter a comma separated list of other tasks to consider as a save. Tasks can include things like publish, unpublish, delete, etc.... But this won't work with JReviews. I tried "save,_save,publish,....

After that I tried to use Developer Events like "listing_was_updated" to trigger the Frontend Secret URL from CacheCleaner like that:

<?php
/**
 * @package     JReviews
 * @author      ClickFWD LLC (https://www.jreviews.com)
 * @copyright   Copyright (C) 2010-2018 ClickFWD LLC
 * @license     GNU GPL version 3 or later
 */
namespace JReviews\Events;

defined('MVC_FRAMEWORK') or die;

use S2App;
use Clickfwd\Event\BaseEvent;
use JReviews\Events\Traits\Helpers;
use JReviews\Events\Traits\Listing;

S2App::import('EventTrait',['helpers','listing'],'jreviews');

class ListingWasUpdated extends BaseEvent
{
	use Helpers;
	use Listing;
	
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://secreturl....";
curl_setopt($ch, CURLOPT_HEADER, false);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
}

Do you have any idea to clean the cache after listings are created or updated?

Best regards

Daniel

Link to comment
  • 3 years later...
×
×
  • Create New...