How do I know a response came from the cache (Cached(HIT) Header Name, default value TRCACHE)?
Short answer
The header set in the Cached(HIT) Header Name field of the Cache profile (default TRCACHE) is added to the responses of the vService to which a Cache profile is assigned: its value is HIT in a response served without going to the Backend Service, and MISS in a response coming from the Backend Service. The header is seen with curl or the developer tools of the browser; the overall status is monitored from the Frontend Cache and Frontend Cache Hit Ratio graphs on the vService dashboard.
Problem: It Is Not Visible Whether the Cache Is Working
After the Cache profile is assigned, the aim is to see which responses come from the cache, how many hits the cache provides and whether the expected files are actually cached.
Solution: Two Methods
| Your situation | Suitable method |
|---|---|
| Checking a single request | Method 1: Response header |
| Monitoring the overall hit ratio | Method 2: Dashboard graphs |
Method 1: Response Header Recommended
- How it works The same address is requested twice; the first response comes from the Backend Service and is written to the cache, the second is served from the cache.
- Where it is opened Client command line or browser → Developer tools → Network
- Requirement HTTP vService with a Cache profile assigned; the requested file must be within the scope of Caching rules
- vService type HTTP
Step-by-Step Configuration
curl -s -o /dev/null -D - https://www.example.com/logo.pngSince -I sends a HEAD request, this form, which uses GET, is preferred. TRCACHE: MISS is seen in the response.
The command is run a second time. In the browser, the same check is done by selecting the request in the Network tab after the page is refreshed and looking at the response headers.
Verification
The response headers of the second request are checked. If the header is not present at all, the Cache profile is not active on the vService, or (in the browser) the response came from the browser's own cache without reaching TR7.
TRCACHE: HITMethod 2: Dashboard Graphs
- How it works Cache lookups, hits and the hit ratio are monitored over time.
- Where it is openedLeft Monitor Panel → Load Balancer vServices → vService → Dashboard → HTTP Frontend
- Requirement HTTP vService with a Cache profile assigned
- vService type HTTP
Step-by-Step Configuration
In the Left Monitor Panel → Load Balancer vServices list, the vService is clicked; the screen opens with the Dashboard tab of the vService (Accessing Dashboard).
On the HTTP Frontend tab, the Frontend Cache (Cache Lookups / Cache Hits) and Frontend Cache Hit Ratio graphs are checked. The instant values are also seen on the cache card in the Frontend section of Live Stats.
Verification
Cache Lookups and Cache Hits are compared. If Lookups increases but Hits does not, the requests match the rule but the responses are not stored.
Cache Hits increases · Hit Ratio greater than zeroDetails of the Header in TR7
- Header name: It is changed in Load Balancer → Profiles → Cache → right-click on the profile row → Edit → Cached(HIT) Header Name field (e.g.
X-Cache). The save is applied without dropping open connections. - Action on cache responses: To apply an action only to the responses served from the cache, the ready If the response comes from cache condition is used, and for the opposite, the If the response DOES NOT come from cache condition (Monitoring the cache performance).
Common Mistakes
- Assuming that MISS shows the response was written to the cache. MISS only shows that the response came from the Backend Service; POST responses also get MISS. Whether it was written to the cache is understood when HIT is seen on the next request.
- Changing the header name and looking for the old name. If the header name has been changed in the Cache profile, it appears in the response with the new name.
- Not checking the rule when always seeing MISS. The file type may not be included in the default rule (e.g.
.js): Which content gets cached; how do I define cache rules?
How it is done in the documentation
