Skip to content

Commit 97a7253

Browse files
author
Jonathan Visser
committed
Fix markdown formatting for improving-varnish-hit-rate-on-hypernode.md
1 parent 86d2167 commit 97a7253

1 file changed

Lines changed: 39 additions & 19 deletions

File tree

docs/hypernode-platform/varnish/improving-varnish-hit-rate-on-hypernode.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
myst:
33
html_meta:
4-
description: Learn how to improve your Varnish cache hit rate on Hypernode by identifying automatic cache purges, analyzing hit/miss patterns, and optimizing URL normalization to boost performance and efficiency.
4+
description: Learn how to improve your Varnish cache hit rate on Hypernode by identifying automatic cache purges, analyzing hit/miss patterns, and optimizing URL normalization to boost performance and efficiency.
55
title: Improving Varnish Cache Hit Rate on Hypernode
66
---
77

@@ -17,13 +17,15 @@ This guide takes you step-by-step from verifying that your cache is active to di
1717
## Before You Begin
1818

1919
Typical cache hit rates:
20-
- **Below 10%** → Cache is barely reused
21-
- **30–70%** → Improvement possible (depends on shop type and traffic patterns)
22-
- **Above 80%** → Generally healthy for most shops
20+
21+
- **Below 10%** → Cache is barely reused
22+
- **30–70%** → Improvement possible (depends on shop type and traffic patterns)
23+
- **Above 80%** → Generally healthy for most shops
2324

2425
Keep in mind:
25-
- Staging environments typically have low hit rates
26-
- B2B webshops often have lower hit rates due to personalization
26+
27+
- Staging environments typically have low hit rates
28+
- B2B webshops often have lower hit rates due to personalization
2729
- Recently flushed caches temporarily reduce hit rates until the cache warms up
2830

2931
Cache hit rate should always be evaluated in context. Traffic volume, personalization, and recent deployments directly affect cache reuse.
@@ -32,11 +34,11 @@ Cache hit rate should always be evaluated in context. Traffic volume, personaliz
3234

3335
A low hit rate does not always indicate a problem. It is normal when:
3436

35-
- Traffic volume is low
36-
- The cache was recently flushed
37-
- Most visitors are logged in
38-
- The shop uses heavy personalization
39-
- You are working in a staging environment
37+
- Traffic volume is low
38+
- The cache was recently flushed
39+
- Most visitors are logged in
40+
- The shop uses heavy personalization
41+
- You are working in a staging environment
4042

4143
Investigate further only if traffic is stable, the cache is warmed up, and the hit rate remains consistently low.
4244

@@ -46,7 +48,8 @@ Ensure Varnish is properly enabled on your vhost and configured in your
4648
application (e.g. Magento 2).
4749

4850
For Magento 2, verify:
49-
- That Varnish is enabled on the vhost
51+
52+
- That Varnish is enabled on the vhost
5053
- Varnish is selected as the caching application
5154
- The correct VCL is generated and loaded
5255
- Full Page Cache (FPC) is enabled
@@ -60,10 +63,13 @@ Tip: The [elgentos/magento2-varnish-extended](https://github.com/elgentos/magent
6063
## Step 2 — Check if Pages Are Being Cached
6164

6265
Using `varnishncsa` from the CLI to see in real time which pages are cached and which are not:
63-
```console
66+
67+
```console
6468
varnishncsa -F '%U%q %{Varnish:hitmiss}x'
6569
```
70+
6671
Look for:
72+
6773
- `hit` → Served from Varnish
6874
- `miss` → Served from backend
6975

@@ -75,16 +81,16 @@ curl -I https://yourdomain.com
7581

7682
Review the following headers:
7783

78-
- **`Set-Cookie`**
84+
- **`Set-Cookie`**\
7985
If a Set-Cookie header (such as PHPSESSID) is present, Varnish will typically not cache the response.
8086

81-
- **`Cache-Control`**
87+
- **`Cache-Control`**\
8288
Should **not** contain `private`, `no-store`, or `no-cache`.
8389

84-
- **`Age`**
90+
- **`Age`**\
8591
Indicates how long (in seconds) the object has been cached.
8692

87-
- **`X-Magento-*`**
93+
- **`X-Magento-*`**\
8894
Provides Magento cache/debug information (visible in developer mode).
8995

9096
If most responses return `MISS` (for example in `X-Magento-Cache-Debug` or similar headers), caching is not being reused effectively.
@@ -101,6 +107,7 @@ varnishstat -1 -f MAIN.cache_hit -f MAIN.cache_miss
101107
```
102108

103109
This shows:
110+
104111
- `MAIN.cache_hit` → Cached responses served
105112
- `MAIN.cache_miss` → Requests sent to backend
106113

@@ -113,6 +120,7 @@ varnishlog
113120
```
114121

115122
Look for:
123+
116124
- `VCL_call HIT` → Served from Varnish
117125
- `VCL_call MISS` → Served from backend
118126
- `Age` → Indicates how long (in seconds) the object has been cached.
@@ -125,6 +133,7 @@ Alternatively, reuse the varnishncsa command from Step 2 for live hit/miss monit
125133
### 1. Pages Bypassing Varnish
126134

127135
Some pages are intentionally not cached:
136+
128137
- Checkout
129138
- Customer account pages
130139
- Requests containing `Set-Cookie` headers
@@ -136,6 +145,7 @@ This is expected behavior.
136145
If cache clears happen frequently, cache reuse becomes nearly impossible.
137146

138147
Common causes:
148+
139149
- Stock or pricing integrations
140150
- Magento cron jobs performing full cache purges
141151
- Extensions invalidating excessive cache entries
@@ -149,12 +159,14 @@ flushes.
149159
Tracking parameters create separate cache entries for identical content.
150160

151161
Examples:
162+
152163
- `utm_source`
153164
- `utm_medium`
154165
- `gclid`
155166
- `fbclid`
156167

157168
Example problem:
169+
158170
- /product-x
159171
- /product-x?utm_source=google
160172

@@ -172,6 +184,7 @@ The [elgentos/magento2-varnish-extended](https://github.com/elgentos/magento2-va
172184
Different URL formats fragment your cache.
173185

174186
Examples:
187+
175188
- `/category` vs `/category/`
176189
- `?Color=Red` vs `?color=red`
177190
- Unsorted query parameters
@@ -190,6 +203,7 @@ grep -R "cacheable=\"false\"" app/code vendor
190203
```
191204

192205
If found:
206+
193207
- Verify the block truly needs to be dynamic
194208
- Remove cacheable="false" if unnecessary
195209
- Use AJAX or Customer Data Sections for dynamic content
@@ -204,7 +218,7 @@ Enable developer mode temporarily for debugging purposes:
204218
magerun2 deploy:mode:set developer
205219
```
206220

207-
Or:
221+
Or:
208222

209223
```console
210224
php bin/magento deploy:mode:set developer
@@ -215,25 +229,31 @@ php bin/magento deploy:mode:set developer
215229
### varnishlog
216230

217231
Inspect detailed request handling:
232+
218233
```console
219234
varnishlog
220235
```
236+
221237
Look for recurring MISS patterns on pages that should be cacheable.
222238

223239
### varnishncsa
224240

225241
Show hit/miss per URL:
242+
226243
```console
227244
varnishncsa -F '%U%q %{Varnish:hitmiss}x'
228245
```
246+
229247
Filter for hits:
248+
230249
```console
231250
varnishncsa -F '%U%q %{Varnish:hitmiss}x' | grep hit
232251
```
233252

234253
### Hypernode Insights (If Available)
235254

236255
Use Hypernode Insights to:
256+
237257
- Monitor hit/miss ratios
238258
- Detect purge spikes
239-
- Correlate cache drops with deployments or cron jobs
259+
- Correlate cache drops with deployments or cron jobs

0 commit comments

Comments
 (0)