Hi All
I have written a Plugin, or am in the process of doing so, that flushes the LS Cache for a specific tag on a Craft CMS website.
My problem is that while the headers get sent ("X-LiteSpeed-Purge":"public,tcb"), the next request still is cached.
I do this upon saving a website entry:
The server response code is 200, the body from the guzzle response contains the actual page content.
Anyone has an idea what I am doing wrong?
I have written a Plugin, or am in the process of doing so, that flushes the LS Cache for a specific tag on a Craft CMS website.
My problem is that while the headers get sent ("X-LiteSpeed-Purge":"public,tcb"), the next request still is cached.
I do this upon saving a website entry:
Code:
/**
* @var Entry $entry
*/
$entry = $event->element;
$elementUrl = $entry->getUrl();
$purgeKey = 'tcb';
$client = Craft::createGuzzleClient();
try {
$request = new Request('GET', $elementUrl, ['X-LiteSpeed-Purge' => 'public,' . $purgeKey]);
$response = $client->send($request);
Craft::$app->getSession()->setError(Craft::t('app', 'Page called: ' . $elementUrl . '(Status: '.$response->getStatusCode() . ')' ) );
} catch (\Exception $e) {
Craft::error('There was a problem parsing the url: ' . $e->getMessage(), __METHOD__);
Craft::$app->getSession()->setError(Craft::t('app', 'Error ('.$elementUrl.'): ' . $e->getMessage(), __METHOD__));
}
Anyone has an idea what I am doing wrong?