Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
72cb9f69
Commit
72cb9f69
authored
Mar 08, 2012
by
Lasse Karstensen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
typos, change example3 to allow for easier purging
parent
4fe672ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
15 deletions
+13
-15
devicedetection.rst
doc/sphinx/tutorial/devicedetection.rst
+13
-15
No files found.
doc/sphinx/tutorial/devicedetection.rst
View file @
72cb9f69
...
...
@@ -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 cache
d
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 add
s
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 {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment