Skip to content

Commit a08e6f9

Browse files
committed
Return cached response if available
1 parent c171d95 commit a08e6f9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/drop-in/advanced-cache.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ public function receive_output(
114114

115115
$cache_key = $method . md5( $_SERVER['REQUEST_URI'] );
116116

117+
$cached = $this->cache->get( $cache_key );
118+
if ( $cached ) {
119+
$response = json_decode( $cached, true );
120+
121+
header( $response['status_header'] );
122+
foreach ( $response['headers'] as $header ) {
123+
header( $header );
124+
}
125+
126+
return $response['body'];
127+
}
128+
117129
$response = [
118130
'body' => $buffer,
119131
'code' => $this->status_code,

0 commit comments

Comments
 (0)