November 26, 2021
5 min read time

Two new VMODS for Varnish Enterprise

We’re happy to announce a new Varnish Enterprise release! Version 6.0.9r1 introduces the Slicer VMOD (which joins the recently added Image VMOD) plus additional improvements and bug fixes. See the full changelog here.

Blog Banner - Varnish Enterprise Release  Version 6.0.9r1

As well as offering professional services, support and enterprise features like MSE, In-process TLS and Edgestash, Varnish Software develops VMODs, which are modules for extending Varnish’s core behavior. We build them in dialogue with our enterprise partners to ensure their effectiveness for real-world use cases, as the two new VMODs demonstrate!

Slicer VMOD - cache partial responses and byte-ranges

The Slicer VMOD allows you to cache partial responses - or “slices” - of files. It does this by issuing range requests to the backend based on the client’s Range header, to fetch only what is needed to satisfy the client’s requested range. While Varnish already handles client-side range requests - fetching the whole file and then serving slices from the cache - this VMOD adds server-side range requests. Find out more about implementation and usage here.

Slicer is useful for streaming services that don’t use segmented video streams, for example if an entire video is stored as and served from a single file. In these environments, it will help with early cancellation of streams, as well as pause, resume and fast forward functionality. Slicer also helps when storing other multi-gigabyte files - such as archive files - on the backend, where clients usually only access a portion of the file. Now, there’s no need to fill the cache with the whole file to serve these requests, so you save vital cache resources.

That’s the benefit of Slicer: reducing unnecessary resource usage and making the cache more efficient. Only the requested parts of a file are cached, so if the rest is never requested or the stream is cancelled, there’s no cache space wasted. We’ve seen Slicer lower resource usage by over 70%! 

Here’s an VCL example of how you can add Slicer VMOD into your Varnish setup:

vcl 4.1;

import slicer;

sub vcl_recv {
    if (req.http.Range) {
        set = "1";

sub vcl_backend_response {
    if ( && !slicer.enable()) {
        set beresp.transit_buffer = 5M;
        return (pass);

This VCL will enable the slicing of object responses in situations where the client presents a Range request header. It also implements Transit Buffer as a fallback, to limit the amount of readahead and buffer size required in case slicing is not possible. Transit Buffer is also how you can set the size of each cache slice.


Image VMOD - cache compressed images in WebP format

Added recently in 6.0.8r7 is the Image VMOD. Use it to compress JPEGs and PNGs into WebP format and store a compressed copy in the cache, reducing file size while maintaining high quality. vmod_image also enables image resizing, for altering image resolution while converting to WebP. See full documentation for vmod_image here.

The Image VMOD is useful for a variety of situations. One example is in businesses where content writers upload articles directly to a CMS with potentially large images attached; it can compress these images at the edge, by default. Another is automatically resizing images to suit the format they are displayed in; thumbnails, for example. 

The following VCL snippet converts JPEG and PNG files to WebP format if it is accepted by the client's browser:

vcl 4.1;

import image;

sub vcl_backend_response {
    if (beresp.http.content-type == "image/jpeg" ||
        beresp.http.content-type == "image/png") {
        if (bereq.http.accept ~ “image/webp”) {
            set beresp.http.Vary = beresp.http.Vary + “ Accept”;


The value in vmod_image comes from being able to deliver images faster from the edge, to save on data costs and speed up your audience’s web experience by avoiding use of unnecessarily large images. The average WebP file size is 25%-34% smaller compared to a JPEG; a significant saving in load time, bandwidth and client data for image-heavy websites. With Varnish Configuration Language’s (VCL) full edge compute capabilities, it’s also possible to set policy rules for vmod_image. Set compression rules per hostname, folder, user, and more.

Full documentation on the new release can be found here.


Working on something that might need a custom VMOD? Perhaps Varnish Enterprise can help! Get in touch 👇

New call-to-action