diff --git a/docker-compose.yml b/docker-compose.yml index e767f3e..dfdc531 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -395,17 +395,17 @@ services: container_name: invidious-cache restart: unless-stopped cpus: 2 - mem_limit: "1024m" - memswap_limit: "1024m" + mem_limit: "512m" + memswap_limit: "512m" image: varnish:latest user: 10043:10043 # Put uid/gid of your invidious user here volumes: - /srv/invidious/varnish:/var/lib/varnish - command: "-a :6081 -T localhost:6082 -f /var/lib/varnish/default.vcl -s file,/var/lib/varnish/varnish_storage.bin,16G -p cli_timeout=15" + command: "-a :6081 -T localhost:6082 -f /var/lib/varnish/default.vcl -s file,/var/lib/varnish/varnish_storage.bin,32G -s Transient=malloc,128m -p cli_timeout=15" ulimits: memlock: - soft: 1073741824 - hard: 1073741824 + soft: 536870912 + hard: 536870912 networks: invidious_proxy: ipv4_address: 192.42.6.3 diff --git a/etc/varnish/default.vcl b/etc/varnish/default.vcl index 86936a1..179bb9f 100644 --- a/etc/varnish/default.vcl +++ b/etc/varnish/default.vcl @@ -4,14 +4,14 @@ backend invidious_service { .host = "192.42.6.2"; .port = "3000"; .connect_timeout = 5s; - .first_byte_timeout = 15s; + .first_byte_timeout = 5s; .between_bytes_timeout = 2s; } sub vcl_recv { set req.backend_hint = invidious_service; - if (req.url ~ "(?i)\.(png|gif|jpg|jpeg|svg)$") { + if (req.url ~ "(?i)\.(css|js|png|gif|jpg|jpeg|svg|woff|woff2)$") { unset req.http.Cookie; } @@ -29,7 +29,12 @@ sub vcl_hash { } sub vcl_backend_response { + set beresp.storage = storage.disk; if (bereq.url ~ "(?i)\.(png|gif|jpg|jpeg|svg)$") { + unset beresp.http.Set-Cookie; + set beresp.ttl = 3d; + } + if (bereq.url ~ "(?i)\.(css|js|woff|woff2)$") { unset beresp.http.Set-Cookie; set beresp.ttl = 7d; } diff --git a/nginx/sites-enabled/invidious.vhost b/nginx/sites-enabled/invidious.vhost index 760007d..c263089 100644 --- a/nginx/sites-enabled/invidious.vhost +++ b/nginx/sites-enabled/invidious.vhost @@ -247,7 +247,7 @@ server { } # Varnish cache - location ~^(/vi/|/ggpht/) { + location ~^(/vi/|/ggpht/|/js/|/css/|/videojs/|/fonts/) { proxy_pass http://varnish_invidious; proxy_set_header Host $host;