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.
id | Constant Name | What it means | used by plugin |
---|---|---|---|
00 | HOME | The homepage | X |
01 | HTML | Any HTML or RSS page | X |
02 | SEARCH | Search page | X |
03 | SITEMAP | Any sitemap xml page | |
10 | POST_TYPE | Post type name | X |
11 | AUTHOR | Author ID | X |
12 | DATE | Full date | X |
13 | MONTH | Month | X |
14 | YEAR | Year | X |
20 | TERM_ID | Taxonomy term ID | X |
21 | TAXONOMY_ID | Taxonomy ID | |
30 | FEEDS | All RSS feeds | X |
31 | COMMENT_FEED | Comment RSS feed | X |
40 | WOOCOMMERCE | Pages generate by WooCommerce | X |
41 | WOOCOMMERCE_SHOP | Shop page of WooCommerce | X |
42 | WOOCOMMERCE_CATEGORY | WooCommerce default category taxonomy | X |
43 | WOOCOMMERCE_TAG | WooCommerce default tag taxonomy | X |
44 | WOOCOMMERCE_PRODUCT | WooCommerce Product page | X |
45 | WOOCOMMERCE_PRODUCT_ID | WooCommerce Product ID | X |