-
-
Notifications
You must be signed in to change notification settings - Fork 35
Add --no-cache global flag to bypass Drupal.org CDN caching
#325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ class Client | |
| */ | ||
| public const API_URL = 'https://www.drupal.org/api-d7/'; | ||
|
|
||
| public function __construct() | ||
| public function __construct(bool $noCache = false) | ||
| { | ||
| $stack = HandlerStack::create(); | ||
| $stack->push(GuzzleRetryMiddleware::factory([ | ||
|
|
@@ -31,16 +31,22 @@ public function __construct() | |
| 'default_retry_multiplier' => 1.5, | ||
| ]), 'retry'); | ||
|
|
||
| $headers = [ | ||
| 'User-Agent' => 'DrupalOrgCli/0.0.1', | ||
| 'Accept' => 'application/json', | ||
| 'Accept-Encoding' => '*', | ||
| ]; | ||
| if ($noCache) { | ||
| $headers['Cache-Control'] = 'no-cache, no-store, max-age=0'; | ||
| $headers['Pragma'] = 'no-cache'; | ||
| } | ||
|
Comment on lines
25
to
+42
|
||
|
|
||
| $this->client = new \GuzzleHttp\Client( | ||
| [ | ||
| 'base_uri' => self::API_URL, | ||
| 'cookies' => true, | ||
| 'handler' => $stack, | ||
| 'headers' => [ | ||
| 'User-Agent' => 'DrupalOrgCli/0.0.1', | ||
| 'Accept' => 'application/json', | ||
| 'Accept-Encoding' => '*', | ||
| ], | ||
| 'headers' => $headers, | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs state
--no-cachesendsCache-Control: no-cache, no-store, must-revalidate, butmust-revalidateisn’t a request directive and may be ignored. Update this section to reflect the actual (standards-aligned) request headers that will be sent after adjusting the client header value.