openstreetmap-tile-server/default.vcl
2021-06-18 11:46:47 +02:00

52 lines
1.1 KiB
Plaintext

vcl 4.1;
import brotli;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don't need,
# rewriting the request, etc.
if(req.http.Accept-Encoding ~ "br" && req.url !~
"\.(jpg|png|gif)$") {
set req.http.X-brotli = "true";
}
}
sub vcl_hash
{
if(req.http.X-brotli == "true") {
hash_data("brotli");
}
}
sub vcl_backend_fetch
{
if(bereq.http.X-brotli == "true") {
set bereq.http.Accept-Encoding = "br";
unset bereq.http.X-brotli;
}
}
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.
}
sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
}