What is tag invalidation and what is it for?

31 Jan 24
A critical part of a website’s proper functioning has to do with controlling cached objects and how and when to invalidate them. In this post, we explain the benefits of using tag invalidation from Transparent Edge’s next-generation CDN.
Tag invalidation allows you to tag groups of objects so that they can be purged quickly, efficiently, and selectively. This avoids the need to devise complex scripts to construct URLs every time content is updated.
For example, let’s say you own a clothing store and you need to reduce the price of outerwear at the end of the winter season to clear out inventory. Without the functionality we’re covering today, you’d have to invalidate each URL on your website that is affected by the sale one by one:
But, if you have previously programmed your CMS to set the “coats” tag to those URLs, simply invalidating the tag will purge all those resources in a matter of seconds.
To solve these kinds of needs, Transparent Edge uses the Surrogate-Keys header. It is used to determine which tags are assigned to an object.
When a non-cached object is requested, we go to the origin. For each object in the origin response, we check for the existence of the Surrogate-Keys header and, if it exists, we assign its value as a tag to the object. If the Surrogate-Keys header value consists of multiple words separated by spaces, we assign all of them to the object.
For instance:
In this case, the object has been tagged with “coats” “men” and “cloth”. Therefore, if we make an invalidation request for “coats” as we proposed above, we will invalidate this object and all objects that include that term, regardless of their URL.
The biggest advantage of tag invalidation is its ability to relate a large number of objects in the origin server response, creating associations between objects at will that we can invalidate in a completely selective way.
On our platform, tags can be generated and assigned in two ways: from the origin server or from the dashboard using VCL language. We address both options in our documentation portal.
However, our recommendation is to implement the tags directly in the application or web server that serves the content from the origin. This makes term assignment much easier and does not require advanced knowledge of VCL.
When invalidating objects using the assigned labels, this can be done from the control panel of our dashboard, and from the API. The first option is easier and you just need to access the Invalidation area of the control panel and activate the tags you want to purge. If you are interested in this topic and have any questions, you can contact our experts to review it in detail.