Skip to content

Commit 12cea6a

Browse files
committed
chore: tweaks at cache middleware
1 parent 71ff0fe commit 12cea6a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

app/Http/Middleware/CacheMiddleware.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function handle($request, Closure $next, $cache_lifetime, $cache_region =
9494

9595
if ($regionTag) {
9696
Log::debug("CacheMiddleware: using region tag {$regionTag} ip {$ip} agent {$agent}");
97-
// try L1 APC
97+
// try L1
9898
$encoded = MemCache::get($key);
9999
$wasMemCacheHit = $encoded !== null;
100100
if($wasMemCacheHit){
@@ -124,14 +124,14 @@ public function handle($request, Closure $next, $cache_lifetime, $cache_region =
124124
});
125125

126126

127-
// backfill APC only if we actually have a value
127+
// backfill Memcache only if we actually have a value
128128
if ($encoded !== null) { // avoid null writes
129129
MemCache::put($key, $encoded, $cache_lifetime, $regionTag);
130130
}
131131
}
132132
$data = $this->decode($encoded);
133133
} else {
134-
// try L1 APC
134+
// try L1
135135
$encoded = MemCache::get($key);
136136
$wasMemCacheHit = !is_null($encoded);
137137
if($wasMemCacheHit){
@@ -157,7 +157,7 @@ public function handle($request, Closure $next, $cache_lifetime, $cache_region =
157157
}
158158
return Cache::get($key);
159159
});
160-
// store at APC
160+
// store at MemCache
161161
if ($encoded !== null) { // avoid null writes
162162
MemCache::put($key, $encoded, $cache_lifetime);
163163
}
@@ -177,7 +177,8 @@ public function handle($request, Closure $next, $cache_lifetime, $cache_region =
177177
$response->headers->addCacheControlDirective('must-revalidate', true);
178178
$response->headers->addCacheControlDirective('proxy-revalidate', true);
179179
$response->headers->add([
180-
'X-Cache-Result' => $wasMemCacheHit ? 'HIT MemcCache' : ($wasHit ? 'HIT REDIS' : 'MISS'),
180+
'X-Cache-Result' => ($wasMemCacheHit || $wasHit) ? 'HIT' : 'MISS',
181+
'X-Cache-Type' => $wasMemCacheHit ? 'M' : ($wasHit ? 'R' : 'N'),
181182
]);
182183
Log::debug( "CacheMiddleware: returning response", [
183184
'ip' => $ip,

0 commit comments

Comments
 (0)