Skip to content

Commit 1163caa

Browse files
committed
cleanup readme a bit
1 parent 101d9af commit 1163caa

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

README.md

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,24 @@ Note that if you are using this, you should have a good purging strategy.
178178
Varnish helper
179179
==============
180180

181+
This helper can be used to talk back to varnish to invalidate cached URLs.
181182
Configure the location of the varnish reverse proxies (be sure not to forget
182-
any, as each varnish must be purged):
183+
any, as each varnish must be notified separately):
183184

184185
``` yaml
185186
# app/config.yml
186187
liip_cache_control:
187188
varnish:
188189
host: http://www.liip.ch
189-
ips: 10.0.0.10, 10.0.0.11 # comma separated list of ips, or an array of ips
190-
port: 80 # port varnish is listening on for incoming web connections
190+
ips: 10.0.0.10, 10.0.0.11
191+
port: 80
191192
```
192193

194+
* **host**: This must match the web host clients are using when connecting to varnish.
195+
You will not notice if this is mistyped, but cache invalidation will never happen.
196+
* **ips**: List of IP adresses of your varnish servers. Comma separated.
197+
* **port**: The port varnish is listening on for incoming web connections.
198+
193199
To use the varnish cache helper you must inject the
194200
``liip_cache_control.varnish`` service or fetch it from the service container:
195201

@@ -223,29 +229,6 @@ Purging
223229
Add the following code to your Varnish configuration to have it handle PURGE
224230
requests (make sure to uncomment the appropiate line(s))
225231

226-
varnish 2.x
227-
```
228-
#top level:
229-
# who is allowed to purge from cache
230-
# https://www.varnish-cache.org/docs/trunk/users-guide/purging.html
231-
acl purge {
232-
"127.0.0.1"; #localhost for dev purposes
233-
"10.0.11.0"/24; #server closed network
234-
}
235-
236-
#in sub vcl_recv
237-
# purge if client is in correct ip range
238-
if (req.request == "PURGE") {
239-
if (!client.ip ~ purge) {
240-
error 405 "Not allowed.";
241-
}
242-
243-
purge("req.url ~ " req.url);
244-
purge("req.url ~ " req.url);
245-
error 200 "Success";
246-
}
247-
```
248-
249232
varnish 3.x
250233
```
251234
#top level:
@@ -284,10 +267,34 @@ sub vcl_miss {
284267

285268
```
286269
270+
In Varnish 2, the `purge` action is actually just marking caches as invalid.
271+
This is called `ban` in Varnish 3.
272+
273+
Varnish 2.x
274+
```
275+
#top level:
276+
# who is allowed to purge from cache
277+
# https://www.varnish-cache.org/docs/trunk/users-guide/purging.html
278+
acl purge {
279+
"127.0.0.1"; #localhost for dev purposes
280+
"10.0.11.0"/24; #server closed network
281+
}
282+
283+
#in sub vcl_recv
284+
# purge if client is in correct ip range
285+
if (req.request == "PURGE") {
286+
if (!client.ip ~ purge) {
287+
error 405 "Not allowed.";
288+
}
289+
290+
purge("req.url ~ " req.url);
291+
purge("req.url ~ " req.url);
292+
error 200 "Success";
293+
}
294+
```
287295
288296
NOTE: this code invalidates the url for all domains. If your varnish serves
289297
multiple domains, you should improve this configuration.
290-
Pull requests welcome :-)
291298
292299
The varnish path invalidation is about equivalent to doing this:
293300
@@ -300,7 +307,9 @@ The varnish path invalidation is about equivalent to doing this:
300307
Banning
301308
-------
302309
303-
Since varnish 3 banning can be used to invalidate the cache.
310+
Since varnish 3 banning can be used to invalidate the cache. Banning
311+
invalidates whole section with regular expressions, so you will need to be
312+
careful to not invalidate too much.
304313
305314
Configure the varnish reverse proxies to use ban as purge instruction:
306315

0 commit comments

Comments
 (0)