summaryrefslogtreecommitdiff
path: root/installation
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2019-01-10 18:28:14 +0000
committerMark Felder <feld@FreeBSD.org>2019-01-10 18:28:14 +0000
commitfda942c329696fc44d3671c5ca58a28c3c38f50a (patch)
tree05ad768404aabdc294b236d20558dde0ad67e374 /installation
parentce224ba5f07d4e699e1652f81d44521b8de19500 (diff)
Cache partial objects for 10 minutes
This enables caching/streaming of chunked responses
Diffstat (limited to 'installation')
-rw-r--r--installation/pleroma.vcl34
1 files changed, 34 insertions, 0 deletions
diff --git a/installation/pleroma.vcl b/installation/pleroma.vcl
index ca79eb7fc..30e552411 100644
--- a/installation/pleroma.vcl
+++ b/installation/pleroma.vcl
@@ -18,6 +18,11 @@ sub vcl_recv {
return (synth(750, ""));
}
+ # CHUNKED SUPPORT
+ if (req.http.Range ~ "bytes=") {
+ set req.http.x-range = req.http.Range;
+ }
+
# Pipe if WebSockets request is coming through
if (req.http.upgrade ~ "(?i)websocket") {
return (pipe);
@@ -56,6 +61,12 @@ sub vcl_backend_response {
set beresp.do_gzip = true;
}
+ # CHUNKED SUPPORT
+ if (bereq.http.x-range ~ "bytes=" && beresp.status == 206) {
+ set beresp.ttl = 10m;
+ set beresp.http.CR = beresp.http.content-range;
+ }
+
# Don't cache objects that require authentication
if (beresp.http.Authorization && !beresp.http.Cache-Control ~ "public") {
set beresp.uncacheable = true;
@@ -111,3 +122,26 @@ sub vcl_pipe {
set bereq.http.connection = req.http.connection;
}
}
+
+sub vcl_hash {
+ # CHUNKED SUPPORT
+ if (req.http.x-range ~ "bytes=") {
+ hash_data(req.http.x-range);
+ unset req.http.Range;
+ }
+}
+
+sub vcl_backend_fetch {
+ # CHUNKED SUPPORT
+ if (bereq.http.x-range) {
+ set bereq.http.Range = bereq.http.x-range;
+ }
+}
+
+sub vcl_deliver {
+ # CHUNKED SUPPORT
+ if (resp.http.CR) {
+ set resp.http.Content-Range = resp.http.CR;
+ unset resp.http.CR;
+ }
+}