Skip to content

Commit

Permalink
Update PurgeCache.php
Browse files Browse the repository at this point in the history
Additionally to PR #7650, when Varnish cache sits behind an NGINX proxy, HTTP code 499 is returned unless socket stream waits for response (which should not have much of a performance impact due to nature of PURGE request)
  • Loading branch information
bery authored Jan 5, 2017
1 parent e6ccdcc commit ad5015e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function sendPurgeRequest($tagsPattern)
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $tagsPattern];
$socketAdapter->setOptions(['timeout' => 10]);
foreach ($servers as $server) {
$headers['Host'] = $server->getHost();
try {
$socketAdapter->connect($server->getHost(), $server->getPort());
$socketAdapter->write(
Expand All @@ -66,6 +67,7 @@ public function sendPurgeRequest($tagsPattern)
'1.1',
$headers
);
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'tagsPattern'));
Expand Down

0 comments on commit ad5015e

Please sign in to comment.