01 Sep 21

Purging

Cache invalidation is a process within a computer system in which cache entries are replaced or removed. In this article we will show you one of our latest updates, the soft purge, which you can use to invalidate content safely even if you have issues in the origin server. 

WHAT IS SOFT PURGING?

When we perform a Soft Purge, the cache object is not purged directly: instead, you mark it as “stale”. The objects marked like that will behave as if their cache life has expired. That way, the next request will go to the origin to look for a new version of this object. 

The main advantage of this type of purge is that if at the time of fetching the new version from the origin backend, the backend doesn’t respond (due to an issue), the “stale” object will be served instead of displaying an error to the end user. Usually, it’s much better to present a stale object rather than an error. 

HOW DO I MAKE A SOFT PURGE REQUEST? 

If you’re using our dashboard, select the “Soft Purge” options.

If you’re using our API, remember to include `”soft”: true` in the JSON payload.

If you want to transform a normal purge into a soft purge when you send an invalidation to our API, you only have to add the field “soft” with the value “true”, to the payload sent in JSON format:

{…, “soft”: true}

This method is compatible with the option of refetching or warm-up cache. 

What are you waiting for to start using it?