[master] 72cb9f6 typos, change example3 to allow for easier purging

Lasse Karstensen lkarsten at varnish-cache.org
Thu Mar 8 14:30:54 CET 2012


commit 72cb9f69167eff08e6498db0ce732eac0e581b20
Author: Lasse Karstensen <lasse at varnish-software.com>
Date:   Thu Mar 8 14:26:27 2012 +0100

    typos, change example3 to allow for easier purging

diff --git a/doc/sphinx/tutorial/devicedetection.rst b/doc/sphinx/tutorial/devicedetection.rst
index a083e6e..abf729e 100644
--- a/doc/sphinx/tutorial/devicedetection.rst
+++ b/doc/sphinx/tutorial/devicedetection.rst
@@ -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 {



More information about the varnish-commit mailing list