Commit cfdf1551 authored by Lasse Karstensen's avatar Lasse Karstensen Committed by Tollef Fog Heen

typos, change example3 to allow for easier purging

parent 2efdcc38
......@@ -27,8 +27,10 @@ Setting this header can be as simple as::
}
}
There are different commercial and free offerings in doing grouping and identifiying clients
in further detail than this.
There are different commercial and free offerings in doing grouping and
identifiying clients in further detail than this. For a basic and community
based regular expression set, see
https://github.com/varnish/varnish-devicedetect/ .
Serve the different content on the same URL
......@@ -45,14 +47,14 @@ Varnish' internal handling of this kicks in.
4. Modify output sent to the client so any caches outside our control don't
serve the wrong content.
All this while still making sure that we only get 1 cache object per URL per
All this while still making sure that we only get 1 cached object per URL per
device class.
Example 1: Send HTTP header to backend
''''''''''''''''''''''''''''''''''''''
The basic case is that Varnish add the X-UA-Device HTTP header on the backend
The basic case is that Varnish adds the X-UA-Device HTTP header on the backend
requests, and the backend mentions in the response Vary header that the content
is dependant on this header.
......@@ -64,17 +66,7 @@ VCL::
sub vcl_recv {
# call some detection engine that set req.http.X-UA-Device
}
sub append_ua_device {
if (req.http.X-UA-Device) {
set bereq.http.X-UA-Device = req.http.X-UA-Device; }
}
# This must be done in vcl_miss and vcl_pass, before any backend request is
# actually sent. vcl_fetch runs after the request to the backend has
# completed.
sub vcl_miss { call append_ua_device; }
sub vcl_pass { call append_ua_device; }
# req.http.X-UA-Device is copied by Varnish into bereq.http.X-UA-Device
# so, this is a bit conterintuitive. The backend creates content based on
# the normalized User-Agent, but we use Vary on X-UA-Device so Varnish will
......@@ -170,7 +162,9 @@ VCL::
sub vcl_recv {
# call some detection engine that set req.http.X-UA-Device
}
sub append_ua {
if ((req.http.X-UA-Device) && (req.request == "GET")) {
# if there are existing GET arguments;
if (req.url ~ "\?") {
......@@ -183,6 +177,10 @@ VCL::
}
}
# do this after vcl_hash, so all Vary-ants can be purged in one go. (avoid ban()ing)
sub vcl_miss { call append_ua; }
sub vcl_pass { call append_ua; }
# Handle redirects, otherwise standard Vary handling code from previous
# examples.
sub vcl_fetch {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment