Skip to main content

Understanding Cache Tags

From version 3.5.11 onwards of the Servebolt Optimizer the performs cache priming and purging via CacheTags when using Accelerated Domains.

The key benefit of cache tags is that it can clear many thousands of URL's in one go while leaving vast portions of the site with caching entact.

When a page is created, updated or deleted, or is comments are approved, or edited, there is a cache purge event that happens for it, and all the places where it might have a reference.

Previously to using cache tags, this might mean many thousands of URLs. For example if a post is authored by the same person who has made 500 other articels, there will be 50+ urls to purge just for the author archive, also the month, year and day archives will need to be purged, as will RSS and the homepage.

If we add on top all of the various tags and categories and their pagination, this can lead to there being many thousands of URL's that need to be purged. This takes time to complete all of them.

With cache tags it take next to no time as each of these archives and taxonomy terms can be purged with only 1 request to clear the cache tag for them. i.e. the author archive stops being 50 urls and becomes just 1 tag. As we can clear 30 tags in one request, this means that we can clear the entire presence of a page on a site incredably quickly.

Cache Tag make-up

We use the strategy of :

[id from inside the environment.json file]-[cache-tag numeric id]-[optonal value for cache tag]-[optional blog-id when on multi-site]

in practice this might look like 1234-11-1-1

This would be the tag associated with the Author Archive of the author 1 on a multisite's 1st blog for the site with the id 1234.

Here is a table of all the cache tag numeric values.

idConstant NameWhat it meansused by plugin
00HOMEThe homepageX
01HTMLAny HTML or RSS pageX
02SEARCHSearch pageX
03SITEMAPAny sitemap xml page
10POST_TYPEPost type nameX
11AUTHORAuthor IDX
12DATEFull dateX
13MONTHMonthX
14YEARYearX
20TERM_IDTaxonomy term IDX
21TAXONOMY_IDTaxonomy ID
30FEEDSAll RSS feedsX
31COMMENT_FEEDComment RSS feedX
40WOOCOMMERCEPages generate by WooCommerceX
41WOOCOMMERCE_SHOPShop page of WooCommerceX
42WOOCOMMERCE_CATEGORYWooCommerce default category taxonomyX
43WOOCOMMERCE_TAGWooCommerce default tag taxonomyX
44WOOCOMMERCE_PRODUCTWooCommerce Product pageX
45WOOCOMMERCE_PRODUCT_IDWooCommerce Product IDX