PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / trunk
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization vtrunk
1.19.8 1.19.7 1.19.6 1.19.5 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.12.0 1.13.0 1.14.0 1.15.0 1.15.1 1.15.2 1.15.3 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.16.6 1.16.7 1.16.8 1.17.0 1.17.6 1.17.7 1.17.8 1.17.9 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.18.5 1.18.6 1.18.7 1.18.8 1.18.9 1.19.0 1.19.1 1.19.2 1.19.3 1.19.4 1.3.19 1.3.20 1.4.0 1.4.1 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.8.1 1.8.3 1.9.0 1.9.1 1.9.2
nitropack / nitropack-sdk / NitroPack / SDK / Api / Warmup.php
nitropack / nitropack-sdk / NitroPack / SDK / Api Last commit date
AdditionalDomains.php 1 year ago Base.php 8 months ago Cache.php 1 year ago ExcludedUrls.php 1 year ago Excludes.php 1 year ago Integration.php 1 year ago RemoteConfigFetcher.php 1 year ago RequestMaker.php 1 year ago Response.php 1 year ago ResponseStatus.php 1 year ago SafeMode.php 1 year ago SecureRequestMaker.php 1 year ago SignedBase.php 1 year ago Stats.php 1 year ago Tagger.php 1 year ago Url.php 1 year ago VariationCookie.php 1 year ago Varnish.php 1 year ago Warmup.php 1 year ago Webhook.php 1 year ago
Warmup.php
157 lines
1 <?php
2 namespace NitroPack\SDK\Api;
3
4 class Warmup extends SignedBase {
5 public function enable() {
6 $path = 'warmup/enable/' . $this->siteId;
7
8 $httpResponse = $this->makeRequest($path);
9
10 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
11 switch ($status) {
12 case ResponseStatus::OK:
13 return true;
14 default:
15 $this->throwException($httpResponse, 'Error while enabling cache warmup: %s');
16 }
17 }
18
19 public function disable() {
20 $path = 'warmup/disable/' . $this->siteId;
21
22 $httpResponse = $this->makeRequest($path);
23
24 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
25 switch ($status) {
26 case ResponseStatus::OK:
27 return true;
28 default:
29 $this->throwException($httpResponse, 'Error while disabling cache warmup: %s');
30 }
31 }
32
33 public function reset() {
34 $path = 'warmup/reset/' . $this->siteId;
35
36 $httpResponse = $this->makeRequest($path);
37
38 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
39 switch ($status) {
40 case ResponseStatus::OK:
41 return true;
42 default:
43 $this->throwException($httpResponse, 'Error while resetting cache warmup: %s');
44 }
45 }
46
47 public function stats() {
48 $path = 'warmup/stats/' . $this->siteId;
49
50 $httpResponse = $this->makeRequest($path);
51
52 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
53 switch ($status) {
54 case ResponseStatus::OK:
55 return json_decode($httpResponse->getBody(), true);
56 default:
57 $this->throwException($httpResponse, 'Error while fetching cache warmup stats: %s');
58 }
59 }
60
61 public function setSitemap($url = NULL) {
62 $path = 'warmup/setsitemap/' . $this->siteId;
63
64 if (!empty($url)) {
65 // Set sitemap URL
66 $post = array(
67 'url' => $url
68 );
69 } else {
70 // Unset sitemap URL
71 $post = array();
72 }
73
74 $httpResponse = $this->makeRequest($path, array(), array(), 'POST', $post);
75
76 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
77 switch ($status) {
78 case ResponseStatus::OK:
79 return true;
80 default:
81 $this->throwException($httpResponse, 'Error while setting sitemap URL: %s');
82 }
83 }
84
85 public function setHomepage($url = NULL) {
86 $path = 'warmup/sethomepageurl/' . $this->siteId;
87
88 if (!empty($url)) {
89 // Set sitemap URL
90 $post = array(
91 'url' => $url
92 );
93 } else {
94 // Unset sitemap URL
95 $post = array();
96 }
97
98 $httpResponse = $this->makeRequest($path, array(), array(), 'POST', $post);
99
100 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
101 switch ($status) {
102 case ResponseStatus::OK:
103 return true;
104 default:
105 $this->throwException($httpResponse, 'Error while setting sitemap URL: %s');
106 }
107 }
108
109 public function estimate($id = NULL, $urls = NULL) {
110 $path = 'warmup/estimate/' . $this->siteId;
111
112 if ($id) {
113 $path .= '/' . $id;
114 }
115
116 $post = array();
117 if (!empty($urls)) {
118 $post = array(
119 'urls' => is_array($urls) ? $urls : [$urls]
120 );
121 }
122
123 $httpResponse = $this->makeRequest($path, array(), array(), 'POST', $post);
124
125 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
126 switch ($status) {
127 case ResponseStatus::OK:
128 return json_decode($httpResponse->getBody(), true);
129 default:
130 $this->throwException($httpResponse, 'Error while setting sitemap URL: %s');
131 }
132 }
133
134 public function run($urls = NULL, $force = false) {
135 $path = 'warmup/run/' . $this->siteId;
136
137 $post = array();
138 if (!empty($urls)) {
139 $post['urls'] = is_array($urls) ? $urls : [$urls];
140 }
141
142 if ($force) {
143 $post['force'] = 1;
144 }
145
146 $httpResponse = $this->makeRequest($path, array(), array(), 'POST', $post);
147
148 $status = ResponseStatus::getStatus($httpResponse->getStatusCode());
149 switch ($status) {
150 case ResponseStatus::OK:
151 return true;
152 default:
153 $this->throwException($httpResponse, 'Error while setting sitemap URL: %s');
154 }
155 }
156 }
157