-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from City-of-Helsinki/UHF-9620
UHF-9620: Purge assets from varnish cache
- Loading branch information
Showing
39 changed files
with
331 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
langcode: en | ||
status: true | ||
dependencies: { } | ||
id: assets | ||
name: Assets | ||
invalidationtype: regex | ||
hostname: localhost | ||
port: 6081 | ||
path: '/[invalidation:expression]' | ||
request_method: BAN | ||
scheme: http | ||
verify: '1' | ||
headers: | ||
- | ||
field: X-VC-Purge-Method | ||
value: regex | ||
- | ||
field: Host | ||
value: localhost | ||
body: null | ||
body_content_type: null | ||
runtime_measurement: true | ||
timeout: 1.0 | ||
connect_timeout: 1.0 | ||
cooldown_time: 0.0 | ||
max_requests: 100 | ||
http_errors: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy; | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\Cache\Context; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\Controller; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\EventSubscriber; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\EventSubscriber; | ||
|
||
use Drupal\helfi_api_base\EventSubscriber\DeployHookEventSubscriberBase; | ||
use Drupal\helfi_proxy\ProxyManagerInterface; | ||
use Drupal\purge\Plugin\Purge\Invalidation\InvalidationsServiceInterface; | ||
use Drupal\purge\Plugin\Purge\Queue\QueueServiceInterface; | ||
use Drupal\purge\Plugin\Purge\Queuer\QueuersServiceInterface; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
/** | ||
* Purge assets from varnish cache. | ||
*/ | ||
final class DeploySubscriber extends DeployHookEventSubscriberBase { | ||
|
||
/** | ||
* Constructs a new instance. | ||
* | ||
* @param \Drupal\helfi_proxy\ProxyManagerInterface $proxyManager | ||
* The proxy manager service. | ||
* @param \Drupal\purge\Plugin\Purge\Invalidation\InvalidationsServiceInterface $invalidationFactory | ||
* The invalidation service. | ||
* @param \Drupal\purge\Plugin\Purge\Queuer\QueuersServiceInterface $queuers | ||
* The queuer service. | ||
* @param \Drupal\purge\Plugin\Purge\Queue\QueueServiceInterface $queue | ||
* The purge queue service. | ||
*/ | ||
public function __construct( | ||
private readonly ProxyManagerInterface $proxyManager, | ||
private readonly InvalidationsServiceInterface $invalidationFactory, | ||
private readonly QueuersServiceInterface $queuers, | ||
private readonly QueueServiceInterface $queue, | ||
) { | ||
} | ||
|
||
/** | ||
* Responds to 'helfi_api_base.post_deploy' event. | ||
* | ||
* @param \Symfony\Contracts\EventDispatcher\Event $event | ||
* The event. | ||
*/ | ||
public function onPostDeploy(Event $event) : void { | ||
if (!$this->proxyManager->isConfigured(ProxyManagerInterface::ASSET_PATH)) { | ||
return; | ||
} | ||
$assetPath = $this->proxyManager->getConfig(ProxyManagerInterface::ASSET_PATH); | ||
|
||
$queuer = $this->queuers->get('helfi_proxy_queue_everything'); | ||
// Purge all assets from Varnish cache. For example: /liikenne-assets/* | ||
// on Liikenne project. | ||
$this->queue->add($queuer, [ | ||
$this->invalidationFactory->get('regex', ltrim($assetPath, '/')), | ||
]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\EventSubscriber; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\EventSubscriber; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\Form; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\PathProcessor; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\Plugin\DebugDataItem; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy\Plugin\Purge\Queuer; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_proxy; | ||
|
||
|
Oops, something went wrong.