Commit 2e933e5d authored by Lasse Karstensen's avatar Lasse Karstensen

cleanup

parent 8c9f5181
Install and configure
=====================
Add the following to your VCL to enable classification::
Serve the different content on the same URL
-------------------------------------------
To serve different content based on the device type, add the following VCL::
"""
include "devicedetect.vcl";
sub vcl_recv {
......@@ -18,18 +22,53 @@ sub vcl_hash {
}
"""
When testing backends you can also add the following include:
This will make a different set of cache objects based on what the client is identified as.
Redirecting mobile clients
--------------------------
If you want to redirect mobile clients instead, you can use::
"""
include "devicedetect.vcl";
sub vcl_recv {
# only do device detection on non-static content.
if (!req.url ~ "^/[^?]+\.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.*|)$") {
call detectdevice;
}
if (req.http.X-UA-Device ~ "^mobile" || req.http.X-UA-device ~ "^tablet") {
error 750 "Moved Teporarily";
}
}
sub vcl_error {
if (obj.status == 750) {
set obj.http.Location = "http://m.example.com/";
set obj.status = 302;
return(deliver);
}
}
"""
This will create the /set_ua_device/ URL which you can use to override the contents of X-UA-Device into the
backend.
Example: enable devicedetection, go to /set_ua_device/mobile-iphone . Afterwards, access your site as usual. The backend will now think that your browser is an iphone, and if configured to it, output different content.
There is an example web server in backend/ that runs on port 8000 and replies differently depending on X-UA-Device. Run
it with:
Testing tools
-------------
There are some tools included for testing and validating your setup.
* backend/example-backend.py
* devicedetect-dev.vcl
If you include the -dev.vcl file, you can access /set_ua_device/ to set a cookie that overrides the value of X-UA-Device
which is sent to the backend. (and used for cache lookups)
Example: enable devicedetection, go to /set_ua_device/mobile-iphone . Afterwards, access your site as usual. You will now
get the content as if your browser was an iPhone. Watch out for the TTL settings.
There is an example web server in backend/ that listens on port 8000 and replies
differently depending on X-UA-Device. Run it with:
cd backend
./example_backend.py
......
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