Skip to content

Commit 17a44e2

Browse files
author
Anton Evers
committed
Add --refresh-content-version-only option to deploy
With this option you can quickly force a browser cache refresh or a CDN cache refresh without having to generate all static content. This comes in handy especially when you have made no code changes, but the CDN failed to update it's cache the last time you deployed or when you have made a manual change in one of the static files as a hotfix on your deployment server, awaiting a suitable moment for deployment to finalize it. This reopens #9338.
1 parent 89e0067 commit 17a44e2

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class DeployStaticOptions
131131
*/
132132
const CONTENT_VERSION = 'content-version';
133133

134+
/**
135+
* Key for refresh content version only mode
136+
*/
137+
const REFRESH_CONTENT_VERSION_ONLY = 'refresh-content-version-only';
138+
134139
/**
135140
* Deploy static command options list
136141
*
@@ -225,6 +230,13 @@ private function getBasicOptions()
225230
'Custom version of static content can be used if running deployment on multiple nodes '
226231
. 'to ensure that static content version is identical and caching works properly.'
227232
),
233+
new InputOption(
234+
self::REFRESH_CONTENT_VERSION_ONLY,
235+
null,
236+
InputOption::VALUE_NONE,
237+
'Refreshing the version of static content only can be used to refresh static content '
238+
. 'in browser cache and CDN cache.'
239+
),
228240
new InputArgument(
229241
self::LANGUAGES_ARGUMENT,
230242
InputArgument::IS_ARRAY,

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public function __construct(
7575
*/
7676
public function deploy(array $options)
7777
{
78+
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
79+
? $options[Options::CONTENT_VERSION]
80+
: (new \DateTime())->getTimestamp();
81+
$this->versionStorage->save($version);
82+
83+
if ($options[Options::REFRESH_CONTENT_VERSION_ONLY]) {
84+
$this->logger->warning(PHP_EOL . "New content version: " . $version);
85+
return;
86+
}
87+
7888
$queue = $this->queueFactory->create(
7989
[
8090
'logger' => $this->logger,
@@ -96,11 +106,6 @@ public function deploy(array $options)
96106
]
97107
);
98108

99-
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
100-
? $options[Options::CONTENT_VERSION]
101-
: (new \DateTime())->getTimestamp();
102-
$this->versionStorage->save($version);
103-
104109
$packages = $deployStrategy->deploy($options);
105110

106111
if ($options[Options::NO_JAVASCRIPT] !== true) {

0 commit comments

Comments
 (0)