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
- Log in to the Magento Admin/Backend as an administrator.
53
-
- Navigate to **Stores > Configuration > Advanced > System > Full Page Cache**
54
-
- From the **Caching Application** list, click `Varnish Caching`
55
-
- Enter a TTL value
56
-
- Expand Varnish Configuration and insert the correct information:
57
-
-`Backend Host`: 127.0.0.1
58
-
-`Backend Port`: 8080
59
-
- Save your VCL by clicking the button **`Save config`** in the top right
60
-
- Click *Export VCL for Varnish 4 or *Export VCL for Varnish 6**
52
+
### Configure Magento to use Varnish
61
53
62
-
### Configure Your Backend Servers Through the Commandline
63
-
64
-
If you want to flush the Varnish cache from the Magento backend, you need to add the Varnish server in your Magento config to `http-cache-hosts`.
65
-
66
-
To do this, run the following command:
54
+
The first step is to configure Magento to make use of the Varnish caching backend and to know which Varnish port needs to be used when flushing the cache.
Now when you flush your caches in cache management, your varnish full_page cache will be flushed too.
74
-
75
-
### Test and Upload Your VCL
76
-
77
-
After downloading your VCL, check (in notepad or something similar) if the following configuration is present:
78
-
79
-
```vcl
80
-
backend default {
81
-
.host = "127.0.0.1";
82
-
.port = "8080";
83
-
}
84
-
```
62
+
Now when you flush your caches in cache management, your Varnish full_page cache will be flushed too.
85
63
86
-
If your VCL checks out, upload it to your Hypernode (using SCP, FTP or FTPS or whichever client you prefer)
64
+
### Generating the VCL
87
65
88
-
#### Remove Health Check Probe from Configuration
66
+
Run the following commands to generate the VCL configuration from Magento. The second command will remove the health check probe, which is not needed for full-page caching.
89
67
90
-
**Note:** The default VCL might have the following configuration:
68
+
In this example, we pass the option `--export-version=6`, change the version number to the Varnish version you're using. As of writing, the following options are supported: 4, 5 and 6. If you're using Varnish 7, you can go with `--export-version=6`.
$ sed -i -E '/[[:space:]]*\.probe[[:space:]]*=[[:space:]]*\{/,/[[:space:]]*}/d' /data/web/magento2.vcl
105
73
```
106
74
107
-
Make sure you change this to the aforementioned configuration (without the health_check probe), since this will break on our Nginx configuration and will therefore result in a `503 Guru Meditation` error.
108
-
109
-
**Note:** If you are using a cluster setup, you need to add some additional configuration to your vcl.
75
+
**Note:** If you are using a cluster setup, you need to add some additional configuration to your VCL.
110
76
The `acl purge` block inside your vcl should contain the private ip range of your cluster.
111
77
You can find your private ip range using the `hypernode-cluster-info` command on one of your cluster nodes.
112
78
@@ -122,23 +88,21 @@ acl purge {
122
88
123
89
## Import Your VCL into the Varnish Daemon
124
90
125
-
Import your VCL into Varnish and save as `mag2`:
91
+
Import your VCL into Varnish and save as `magento2`:
The output should say: *your VCL is compiled*. If you receive a `Permission denied` error, and have recently activated Varnish, please close all ssh sessions, and log back in to reload your new permissions.
133
98
134
99
Now tell Varnish to activate the loaded VCL:
135
100
136
101
```console
137
-
$ varnishadm vcl.use mag2
138
-
102
+
$ varnishadm vcl.use magento2
139
103
```
140
104
141
-
In the examples we used the name ‘mag2’ for our VCL, but you can use any name you prefer.
105
+
In the examples we used the name ‘magento2’ for our VCL, but you can use any name you prefer.
0 commit comments