You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-7Lines changed: 29 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Cache Tag
2
2
3
-
Cloudflare has the ability to index cached resources by _tag_ which allows those resources be
3
+
[Cloudflare](https://www.cloudflare.com/) has the ability to index cached resources by _tag_ which allows those resources be
4
4
[purged by tag](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/). However, this feature is
5
5
[only available for Enterprise customers](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/#:~:text=Note%20that%20Tag%2C%20Hostname%20and%20Prefix%20purges%20are%20only%20available%20for%20Enterprise%20customers.).
6
6
@@ -22,22 +22,44 @@ This application is broken up into three [Workers](https://developers.cloudflare
22
22
23
23
#### [Watcher](./workers/watcher/)
24
24
25
-
This worker watches requests to the Cloudflare Cache / Origin, captures the tags, and sends them to the
26
-
[Controller](./workers/controller/) in order to be persisted.
25
+
This worker watches requests to the Cloudflare [Cache](https://developers.cloudflare.com/cache/) / Origin, captures the
26
+
tags, and sends them to the [Controller](./workers/controller/) in order to be persisted.
27
27
28
28
> [!IMPORTANT]
29
29
> By the time a response from an origin reaches a [Worker](https://developers.cloudflare.com/workers/), Cloudflare
30
-
> has already swallowed the `Cache-Tag` header and it is not longer available. To get around this, the worker reads the
30
+
> has already swallowed the `Cache-Tag` header and it is no longer available. To get around this, the worker reads the
31
31
> custom `X-Cache-Tag` header instead.
32
32
33
33
The worker also exposes a `/.cloudflare/purge` endpoint that allows tags to be purged. This endpoint matches the
34
34
[interface of the Cloudflare endpoint](https://developers.cloudflare.com/api/operations/zone-purge#purge-cached-content-by-tag-host-or-prefix), but only allows `tags`. The tags that are purged will be scoped
35
-
to the zone in which the request is made too. For example, a purge request to `https://example.com/.cloudflare/purge`
36
-
would only purge resources from the `example.com` zone.
35
+
to the [zone](https://developers.cloudflare.com/fundamentals/setup/accounts-and-zones/#zones) in which the request is
36
+
made too. For example, a purge request to `https://example.com/.cloudflare/purge` would only purge resources from the
[CF-Worker](https://developers.cloudflare.com/fundamentals/reference/http-request-headers/#cf-worker) which gets added
50
+
to outbound requests from a [Worker](https://developers.cloudflare.com/workers/). Unfortunately this header does not
51
+
exist when using [Service Bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/).
52
+
The only way to retrieve the header is by making a request to the [Worker](https://developers.cloudflare.com/workers/)
53
+
on the provided [workers.dev subdomain](https://developers.cloudflare.com/workers/configuration/routing/workers-dev/).
54
+
55
+
The [Controller](./workers/controller/) exists primarily as an intermediary between [Watcher](./workers/watcher/) and [Handler](./workers/handler/) to collect zone information. It is **not** included as a part of [Handler](./workers/handler/) in order to ensure that the [Worker](https://developers.cloudflare.com/workers/) is collocated in the
56
+
[same data center](https://developers.cloudflare.com/workers/configuration/smart-placement/) as
57
+
[Watcher](./workers/watcher/).
58
+
59
+
The worker also exposes a `/purge` endpoint that allows tags to be purged. This endpoint matches the
60
+
[interface of the Cloudflare endpoint](https://developers.cloudflare.com/api/operations/zone-purge#purge-cached-content-by-tag-host-or-prefix), but only allows `tags`. Since no
61
+
[zone](https://developers.cloudflare.com/fundamentals/setup/accounts-and-zones/#zones) information is provided, matching
0 commit comments