Skip to content

Commit d7b79e0

Browse files
authored
Merge pull request #322 from FriendsOfSymfony/varnish5
Add Varnish 5 compatibility
2 parents c73e722 + e308eb1 commit d7b79e0

24 files changed

+58
-43
lines changed

.travis.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
dist: trusty
2+
group: edge
13
language: php
24

35
php:
@@ -7,12 +9,14 @@ php:
79
- 7
810

911
env:
10-
- VARNISH_VERSION=4.0
12+
- VARNISH_VERSION=5.0.0
1113

1214
matrix:
1315
include:
1416
- php: 5.5
1517
env: SYMFONY_VERSION=2.7.* VARNISH_VERSION=3.0 COMPOSER_FLAGS="--prefer-lowest"
18+
- php: 7.0
19+
env: VARNISH_VERSION=4.1
1620

1721
branches:
1822
only:
@@ -25,10 +29,19 @@ install:
2529

2630
before_script:
2731
# Install Varnish
28-
- curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
29-
- echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-${VARNISH_VERSION}" | sudo tee -a /etc/apt/sources.list
30-
- sudo apt-get update -qq
31-
- sudo apt-get install -qq varnish python-sphinx enchant
32+
- |
33+
if [ "$VARNISH_VERSION" = "5.0.0" ]; then
34+
wget https://repo.varnish-cache.org/pkg/${VARNISH_VERSION}/varnish_${VARNISH_VERSION}-1_amd64.deb
35+
sudo dpkg -i varnish_${VARNISH_VERSION}-1_amd64.deb
36+
sudo apt-get update -qq
37+
sudo apt-get -f install
38+
else
39+
curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
40+
echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-${VARNISH_VERSION}" | sudo tee -a /etc/apt/sources.list
41+
sudo apt-get update -qq
42+
sudo apt-get install -qq varnish
43+
fi
44+
- sudo apt-get install -qq python-sphinx enchant
3245
- sudo pip install -r doc/requirements.txt
3346
# Install NGINX
3447
- sh ./tests/install-nginx.sh

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
2929

3030
* Varnish configuration are now files that you can directly include from your
3131
.vcl and call custom functions to avoid copy-pasting VCL code.
32-
* Changed default Varnish version to 4.
32+
* Moved Varnish 4 and 5 configuration files from `resources/config/varnish-4/`
33+
to `resources/config/varnish/`.
34+
* Changed default Varnish version to 5.
3335

3436
### NGINX
3537

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Features
2727
with minimal impact on performance.
2828
* Cache tagging abstraction, uses BAN with Varnish and allows tagging support for other caching proxies in the future.
2929
* Use the built-in support for [Varnish](http://foshttpcache.readthedocs.org/en/stable/varnish-configuration.html)
30-
3 and 4, [NGINX](http://foshttpcache.readthedocs.org/en/stable/nginx-configuration.html), the
30+
3, 4 and 5, [NGINX](http://foshttpcache.readthedocs.org/en/stable/nginx-configuration.html), the
3131
[Symfony reverse proxy from the http-kernel component](http://foshttpcache.readthedocs.org/en/stable/symfony-cache-configuration.html)
3232
or easily implement your own caching proxy client.
3333
* [Test your application](http://foshttpcache.readthedocs.org/en/stable/testing-your-application.html)

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
# General information about the project.
5454
project = 'FOSHttpCache'
55-
copyright = '2014, FriendsOfSymfony'
55+
copyright = u'2014–2016, FriendsOfSymfony'
5656

5757
# The version info for the project you're documenting, acts as replacement for
5858
# |version| and |release|, also used in various other places throughout the
@@ -263,5 +263,5 @@ def setup(app):
263263

264264
config_block = {
265265
'varnish3': 'Varnish 3',
266-
'varnish4': 'Varnish 4'
266+
'varnish4': 'Varnish 4 & 5'
267267
}

doc/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Overview
5757
This library mainly consists of:
5858

5959
* low-level clients for communicating with a proxy server (Varnish, NGINX and
60-
Symfony `HttpCache`)
60+
Symfony HttpCache)
6161
* a cache invalidator that acts as an abstraction layer for the proxy
6262
client
6363
* test classes that you can use for integration testing your application

doc/varnish-configuration.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Varnish Configuration
44
---------------------
55

66
Below you will find detailed Varnish configuration recommendations for the
7-
features provided by this library. The configuration is provided for Varnish 3
8-
and 4.
7+
features provided by this library. The configuration is provided for Varnish 3,
8+
4 and 5.
99

1010
Basic Varnish Configuration
1111
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -14,7 +14,7 @@ To invalidate cached objects in Varnish, begin by adding an `ACL`_ (for Varnish
1414
3 see `ACL for Varnish 3`_) to your Varnish configuration. This ACL determines
1515
which IPs are allowed to issue invalidation requests. To use the provided
1616
configuration fragments, this ACL has to be named ``invalidators``. The most
17-
simple ACL, valid for both Varnish 4 and Varnish 3, looks as follows:
17+
simple ACL, valid for all Varnish versions from 3 onwards, looks as follows:
1818

1919
.. code-block:: varnish4
2020
@@ -61,7 +61,7 @@ To enable support add the following to ``your_varnish.vcl``:
6161

6262
.. code-block:: varnish4
6363
64-
include "path-to-config/varnish-4/fos_purge.vcl";
64+
include "path-to-config/varnish/fos_purge.vcl";
6565
6666
sub vcl_recv {
6767
call fos_purge_recv;
@@ -102,7 +102,7 @@ To enable support, add the following to ``your_varnish.vcl``:
102102

103103
.. code-block:: varnish4
104104
105-
include "path-to-config/varnish-4/fos_refresh.vcl";
105+
include "path-to-config/varnish/fos_refresh.vcl";
106106
107107
sub vcl_recv {
108108
call fos_refresh_recv;
@@ -131,7 +131,7 @@ To enable support add the following to ``your_varnish.vcl``:
131131

132132
.. code-block:: varnish4
133133
134-
include "path-to-config/varnish-4/fos_ban.vcl";
134+
include "path-to-config/varnish/fos_ban.vcl";
135135
136136
sub vcl_recv {
137137
call fos_ban_recv;
@@ -185,7 +185,7 @@ VCL will look like this:
185185

186186
.. configuration-block::
187187

188-
.. literalinclude:: ../resources/config/varnish-4/fos_ban.vcl
188+
.. literalinclude:: ../resources/config/varnish/fos_ban.vcl
189189
:language: varnish4
190190
:emphasize-lines: 17-22,49-50
191191
:linenos:
@@ -212,8 +212,8 @@ To enable support add the following to ``your_varnish.vcl``:
212212

213213
.. code-block:: varnish4
214214
215-
include "path-to-config/varnish-4/fos_user_context.vcl";
216-
include "path-to-config/varnish-4/fos_user_context_url.vcl";
215+
include "path-to-config/varnish/fos_user_context.vcl";
216+
include "path-to-config/varnish/fos_user_context_url.vcl";
217217
218218
sub vcl_recv {
219219
call fos_user_context_recv;
@@ -230,7 +230,7 @@ To enable support add the following to ``your_varnish.vcl``:
230230
.. code-block:: varnish3
231231
232232
include "path-to-config/varnish-3/fos_user_context.vcl";
233-
include "path-to-config/varnish-4/fos_user_context_url.vcl";
233+
include "path-to-config/varnish/fos_user_context_url.vcl";
234234
235235
sub vcl_recv {
236236
call fos_user_context_recv;
@@ -291,7 +291,7 @@ values are different for each request. Because of this, the hash request would
291291
not be cached, but multiple hashes would be generated for one and the same user.
292292

293293
To make the hash request cacheable, you must extract a stable user session id
294-
*before calling ``fos_user_context_recv``*. You can do this as
294+
*before* calling ``fos_user_context_recv``. You can do this as
295295
`explained in the Varnish documentation`_:
296296

297297
.. code-block:: varnish4
@@ -331,7 +331,7 @@ inline C enabled: ``-p vcc_allow_inline_c=on``. Then add the following to
331331

332332
.. code-block:: varnish4
333333
334-
include "path-to-config/varnish-4/fos_custom_ttl.vcl";
334+
include "path-to-config/varnish/fos_custom_ttl.vcl";
335335
336336
sub vcl_backend_response {
337337
call fos_custom_ttl_backend_response;
@@ -364,7 +364,7 @@ To enable support add the following to ``your_varnish.vcl``:
364364

365365
.. code-block:: varnish4
366366
367-
include "path-to-config/varnish-4/fos_debug.vcl";
367+
include "path-to-config/varnish/fos_debug.vcl";
368368
369369
sub vcl_deliver {
370370
call fos_debug_deliver;

tests/Functional/Fixtures/varnish-4/custom_ttl.vcl renamed to tests/Functional/Fixtures/varnish/custom_ttl.vcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
vcl 4.0;
22

3-
include "../../../../resources/config/varnish-4/fos_debug.vcl";
4-
include "../../../../resources/config/varnish-4/fos_custom_ttl.vcl";
3+
include "../../../../resources/config/varnish/fos_debug.vcl";
4+
include "../../../../resources/config/varnish/fos_custom_ttl.vcl";
55

66
backend default {
77
.host = "127.0.0.1";

tests/Functional/Fixtures/varnish-4/fos.vcl renamed to tests/Functional/Fixtures/varnish/fos.vcl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
vcl 4.0;
22

3-
include "../../../../resources/config/varnish-4/fos_debug.vcl";
4-
include "../../../../resources/config/varnish-4/fos_refresh.vcl";
5-
include "../../../../resources/config/varnish-4/fos_purge.vcl";
6-
include "../../../../resources/config/varnish-4/fos_ban.vcl";
3+
acl invalidators {
4+
"127.0.0.1";
5+
}
6+
7+
include "../../../../resources/config/varnish/fos_debug.vcl";
8+
include "../../../../resources/config/varnish/fos_refresh.vcl";
9+
include "../../../../resources/config/varnish/fos_purge.vcl";
10+
include "../../../../resources/config/varnish/fos_ban.vcl";
711

812
backend default {
913
.host = "127.0.0.1";
1014
.port = "8080";
1115
}
1216

13-
acl invalidators {
14-
"127.0.0.1";
15-
}
16-
1717
sub vcl_recv {
1818
call fos_ban_recv;
1919
call fos_purge_recv;

tests/Functional/Fixtures/varnish-4/user_context.vcl renamed to tests/Functional/Fixtures/varnish/user_context.vcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
include "../../../../resources/config/varnish-4/fos_user_context.vcl";
2-
include "../../../../resources/config/varnish-4/fos_debug.vcl";
1+
include "../../../../resources/config/varnish/fos_user_context.vcl";
2+
include "../../../../resources/config/varnish/fos_debug.vcl";
33

44
sub vcl_recv {
55
call fos_user_context_recv;
@@ -12,4 +12,4 @@ sub vcl_backend_response {
1212
sub vcl_deliver {
1313
call fos_debug_deliver;
1414
call fos_user_context_deliver;
15-
}
15+
}

tests/Functional/Varnish/CustomTtlTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public function setUp()
3030
protected function getConfigFile()
3131
{
3232
switch ((int) $this->getVarnishVersion()) {
33-
case 4:
34-
return './tests/Functional/Fixtures/varnish-4/custom_ttl.vcl';
35-
default:
33+
case 3:
3634
return './tests/Functional/Fixtures/varnish-3/custom_ttl.vcl';
35+
default:
36+
return './tests/Functional/Fixtures/varnish/custom_ttl.vcl';
3737
}
3838
}
3939

tests/Functional/Varnish/UserContextCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function getConfigFile()
2323
case 3:
2424
return './tests/Functional/Fixtures/varnish-3/user_context_cache.vcl';
2525
default:
26-
return './tests/Functional/Fixtures/varnish-4/user_context_cache.vcl';
26+
return './tests/Functional/Fixtures/varnish/user_context_cache.vcl';
2727
}
2828
}
2929

tests/Functional/Varnish/UserContextFailureTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function getConfigFile()
9999
case 3:
100100
return sprintf('./tests/Functional/Fixtures/varnish-3/user_context_%s.vcl', $this->mode);
101101
default:
102-
return sprintf('./tests/Functional/Fixtures/varnish-4/user_context_%s.vcl', $this->mode);
102+
return sprintf('./tests/Functional/Fixtures/varnish/user_context_%s.vcl', $this->mode);
103103
}
104104
}
105105
}

tests/Functional/Varnish/UserContextNocacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function getConfigFile()
2323
case 3:
2424
return './tests/Functional/Fixtures/varnish-3/user_context_nocache.vcl';
2525
default:
26-
return './tests/Functional/Fixtures/varnish-4/user_context_nocache.vcl';
26+
return './tests/Functional/Fixtures/varnish/user_context_nocache.vcl';
2727
}
2828
}
2929

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
) {
2121
define('VARNISH_FILE', './tests/Functional/Fixtures/varnish-3/fos.vcl');
2222
} else {
23-
define('VARNISH_FILE', './tests/Functional/Fixtures/varnish-4/fos.vcl');
23+
define('VARNISH_FILE', './tests/Functional/Fixtures/varnish/fos.vcl');
2424
}
2525
}
2626

0 commit comments

Comments
 (0)