---
name: "vmod_softpurge"
section: "3"
platform: "linux"
package: "varnish-modules"
version: "0.9.1-4"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/vmod_softpurge"
---

# vmod\_softpurge(3)

purge vmod

## NAME

vmod\_softpurge - purge vmod

## SYNOPSIS

import softpurge \[from "path"\] ;

## DESCRIPTION

**Softpurge** is cache invalidation in Varnish that reduces TTL but keeps the grace value of a resource.

This makes it possible to serve stale content to users if the backend is unavailable and fresh content can not be fetched.

## CONTENTS

- •

  *func\_softpurge*

### softpurge

```
VOID softpurge()
```

Performs a soft purge. Valid in vcl\_hit and vcl\_miss.

Example:

```
sub vcl_hit {
    if (req.method == "PURGE") {
        softpurge.softpurge();
    }
}
```

## USAGE

In your VCL you could then use this vmod along the following lines:

```
import softpurge;
sub vcl_recv {
    if (req.method == "PURGE") {
        return (hash);
    }
}
sub vcl_backend_response {
    set beresp.grace = 10m;
}
sub vcl_hit {
    if (req.method == "PURGE") {
        softpurge.softpurge();
        return (synth(200, "Successful softpurge"));
    }
}
sub vcl_miss {
    if (req.method == "PURGE") {
        softpurge.softpurge();
        return (synth(200, "Successful softpurge"));
    }
}
```
