~slink/libvmod-zipflow

A Varnish Delivery Processor (VDP) interface to Mark Adler's zipflow library to package and compress responses into the ZIP format.
afe3679e — Nils Goroll 3 months ago
Update zipflow
ae13622a — Nils Goroll 3 months ago
Update to Varnish-Cache 7.5
dd88f32c — Nils Goroll 1 year, 4 months ago
Implement set_level

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~slink/libvmod-zipflow
read/write
git@git.sr.ht:~slink/libvmod-zipflow

You can also use your local clone with git send-email.


#title: "vmod zipflow: On-the-fly ZIP bundling for Varnish Cache"

This module provides a Varnish-Cache Delivery Processor (VDP) interface to Mark Adler's zipflow library to package and compress responses into the ZIP format.

#PROJECT RESOURCES

You may also use the sourcehut git repository.

#INTRODUCTION

Using this VMOD, ZIP responses can be generated on the fly from an arbitrary number of objects. The mechanism is similar to ESI handling in Varnish-Cache: For each object to be added as a file in the ZIP archive, a sub-request is generated.

The resulting ZIP is generated while it is being delived. It is not stored (this can, however, be achieved with requests from varnish to itself).

#Examples

Example: Send the response body as a zip file containing "filename":

import zipflow;

sub vcl_init {
    zipflow.set_level(9);
}

sub vcl_deliver {
    zipflow.meta("filename");
    set resp.filters += " zipflow";
}

Example: Create a two subrequests for other URLs, which are bundled into the ZIP response:

import zipflow;

sub vcl_recv {
    if (req.url == "/zip") {
        return (synth(1200));
    }
}

sub synth_zipflow {
    if (zipflow.is_subreq()) {
        return;
    }
    # activate zipflow
    set resp.filters = "zipflow";
    set resp.body = " "; // REQUIRED!

    # do not put this body into the zip
    zipflow.bundle(false);

    # create two subrequests to put into the zip
    zipflow.subreq("/file1");
    zipflow.subreq("/file2");
    return (deliver);
}

sub vcl_synth {
    if (resp.status == 1200) {
        call synth_zipflow;
    }
}

This README is only intended as a first introduction, for more details, please refer to the vmod_zipflow(3) man page. If you are reading this file on line, it should also be available as vmod_zipflow.man.md.

#INSTALLATION

See INSTALL.md.

#SUPPORT

To report bugs, please use the sourcehut bug tracker.

For enquiries about professional service and support, please contact info@uplex.de.

#CONTRIBUTING

To contribute to the project, please use the sourcehut bug tracker.

To support the project's development and maintenance, there are several options:

  • Donate money through paypal. If you wish to receive a commercial invoice, please add your details (address, email, any requirements on the invoice text) to the message sent with your donation.
  • Become a github sponsor.
  • Contact info@uplex.de to receive a commercial invoice for SWIFT payment.

#ACKNOWLEDGEMENTS

This project was greatly facilitated by Mark Adler's zipflow library.

Copyright 2022, 2023 UPLEX Nils Goroll Systemoptimierung
All rights reserved

Author: Nils Goroll <nils.goroll@uplex.de>

See LICENSE
Do not follow this link