You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/hypernode-platform/varnish/improving-varnish-hit-rate-on-hypernode.md
+61-32Lines changed: 61 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,32 +7,46 @@ myst:
7
7
8
8
# Improving Your Varnish Cache Hit Rate
9
9
10
-
A higher Varnish cache hit rate means more requests are served directly from cache.
10
+
A higher Varnish cache hit rate means more requests are served directly from the cache.
11
11
This reduces resource usage on your Hypernode, improves page load speed, and helps your shop handle more concurrent visitors without performance degradation.
12
12
13
-
A low hit rate often indicates that cache isn’t being reused effectively, typically caused by misconfiguration, frequent invalidation, or too much variation in URLs.
13
+
A low hit rate often indicates that cache is not being reused effectively, typically caused by misconfiguration, frequent invalidation, or too much variation in URLs.
14
14
15
15
This guide takes you step-by-step from verifying that your cache is active to diagnosing and improving your hit ratio.
16
16
17
17
## Before You Begin
18
18
19
19
Typical cache hit rates:
20
20
-**Below 10%** → Cache is barely reused
21
-
-**30–70%** → Improvement possible (depends on shop type)
22
-
-**Above 80%** → Generally healthy
21
+
-**30–70%** → Improvement possible (depends on shop type and traffic patterns)
22
+
-**Above 80%** → Generally healthy for most shops
23
23
24
24
Keep in mind:
25
25
- Staging environments typically have low hit rates
26
26
- B2B webshops often have lower hit rates due to personalization
27
+
- Recently flushed caches temporarily reduce hit rates until the cache warms up
27
28
29
+
Cache hit rate should always be evaluated in context. Traffic volume, personalization, and recent deployments directly affect cache reuse.
28
30
29
-
# Step 1 — Verify Varnish Is Enabled
31
+
## When a Low Hit Rate Is Expected
32
+
33
+
A low hit rate does not always indicate a problem. It is normal when:
34
+
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
40
+
41
+
Investigate further only if traffic is stable, the cache is warmed up, and the hit rate remains consistently low.
42
+
43
+
## Step 1 — Verify Varnish Is Enabled
30
44
31
45
Ensure Varnish is properly enabled on your vhost and configured in your
32
46
application (e.g. Magento 2).
33
47
34
48
For Magento 2, verify:
35
-
- That varnish is enabled on the vhost
49
+
- That Varnish is enabled on the vhost
36
50
- Varnish is selected as the caching application
37
51
- The correct VCL is generated and loaded
38
52
- Full Page Cache (FPC) is enabled
@@ -43,9 +57,17 @@ For a step-by-step guide on activating and configuring Varnish in Magento 2, ple
43
57
Tip: The [elgentos/magento2-varnish-extended](https://github.com/elgentos/magento2-varnish-extended) extension improves Magento’s default VCL configuration and marketing parameter handling.
44
58
```
45
59
46
-
# Step 2 — Check if Pages Are Being Cached
60
+
## Step 2 — Check if Pages Are Being Cached
61
+
62
+
Using `varnishncsa` from the CLI to see in real time which pages are cached and which are not:
63
+
```console
64
+
varnishncsa -F '%U%q %{Varnish:hitmiss}x'
65
+
```
66
+
Look for:
67
+
-`hit` → Served from Varnish
68
+
-`miss` → Served from backend
47
69
48
-
Use`curl` to inspect response headers:
70
+
Alternatively, you can use`curl` to inspect response headers:
49
71
50
72
```console
51
73
curl -I https://yourdomain.com
@@ -54,7 +76,7 @@ curl -I https://yourdomain.com
54
76
Review the following headers:
55
77
56
78
-**`Set-Cookie`**
57
-
If `PHPSESSID` is present, Varnish will not cache the response.
79
+
If a Set-Cookie header (such as PHPSESSID) is present, Varnish will typically not cache the response.
58
80
59
81
-**`Cache-Control`**
60
82
Should **not** contain `private`, `no-store`, or `no-cache`.
@@ -70,7 +92,7 @@ If most responses return `MISS` (for example in `X-Magento-Cache-Debug` or simil
70
92
You can also inspect these headers in your browser via:
0 commit comments