Skip to content

Commit

Permalink
[TASK] Add documentation for v4
Browse files Browse the repository at this point in the history
  • Loading branch information
bmack committed Feb 12, 2024
1 parent 1731240 commit 0b930d2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 33 deletions.
42 changes: 9 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ This TYPO3 extension is a flexible and generic way to track the pages that are c
nginx or varnish, or any useful CDN.

Currently supported backends / providers:
* Cloudflare CDN
* Fastly CDN
* Varnish via curl
* plain curl
* Cloudflare CDN (https://packagist.org/packages/b13/cloudflare-cdn)
* Akamai CDN (https://packagist.org/packages/b13/akamai)
* Azure CDN (https://packagist.org/packages/b13/azure-purge)

What does it do?
----------------
By embracing TYPO3's Caching Framework this extension provides a new cache to track all pages outputted that are
"cacheable". When an editor changes content on a page, the page cache needs to be cleared - and the CDN / reverse proxy
needs to be informed that the cache is invalid. This is usually done via a HTTP PURGE request to the CDN / proxy server.
needs to be informed that the cache is invalid. This is usually done via a HTTP PURGE request to the CDN / proxy server
or a custom API.

The benefits for that are that the editor does not need to worry why out-of-date information is still visible
on his/her website.

Requirements
------------
* A TYPO3 setup (v9 LTS+) with cacheable content, see the "cacheinfo" extension for what can be tracked with HTTP caches.
* Either nginx or varnish configured to proxy the TYPO3 system. For nginx, make sure that nginx is compiled to allow
to flush caches via HTTP `PURGE`. Alternatively, use a CDN like Fastly or Cloudflare for playing around with it.
* A TYPO3 setup (v11 LTS+) with cacheable content, see the "cacheinfo" extension for what can be tracked with HTTP caches.
* A CDN or Reverse Proxy (such as nginx or apache2)

Setup
-----
Expand All @@ -36,27 +35,7 @@ Whenever a cacheable frontend page is now called, the full URL is stored in a ca
table is emptied completely, additionally, a HTTP PURGE call to the reverse proxy is made to empty all caches.
If only a certain tag is removed, the PURGE call is made only to the relevant URLs that are stored in the cache.

### Fastly

Fastly makes a direct HTTP PURGE call to a specific URL, so it needs to be ensured that the request comes directly
from the production environment (CDN backend server) where access to fastly is allowed, and PURGE requests are accepted.

Ensure to set the environment variables `FASTLY_SERVICE_ID` and `FASTLY_API_TOKEN`.

### Cloudflare

Cloudflare v4 API is used to make HTTP requests via Guzzle HTTP and API Tokens. This is done by firing HTTP POST
requests to purge one, multiple or all requests on a domain.

Ensure to set the environment variable `CLOUDFLARE_API_TOKEN` in place.

#### Configuration

Add this to your `AdditionalConfiguration.php` file:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['proxycachemanager']['cloudflare']['zones'] = [
'example.com' => 'MY_ZONE_ID'
];
### Configuration

By default all administrators can flush the CDN caches via the toolbar
on the top right corner of TYPO3's Backend.
Expand All @@ -70,12 +49,9 @@ UserTsConfig option:

`options.clearCache.proxy = 0`

#### Limitations
- Only API Token authentication is available
- It is not possible to flush by tag (Enterprise Only)

Credits
-------

The extension was created taken all the great from Andreas Gellhaus, Tom Rüther into account, as well
as `moc_varnish` and `cacheinfo` as great work before.

Expand Down
38 changes: 38 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Upgrade Instructions

v3 => v4

Proxycachemanager v3 served for many years as a well thought out basis
for extending the interface for any kind of proxy and CDN adapter.

However, some functionality has been removed and adapted,
here is a list of features that have been removed or changed:

## Removed Functionality

* Cloudflare CDN Cache Provider
* Curl HTTP Cache Provider
* Fastly CDN Cache Provider
* Varnish HTTP Cache Provider

These features can be added in separate extensions requiring
proxycachemanager, and utilizing even more functionality.

In case you need them, we suggest moving the code from "proxycachemanager"
v3 into your extension code, and then adapt to the updated
interface.

## Adapted "ProxyProviderInterface"

The main interface "ProxyProviderInterface" has the following methods removed:

* "setProxyEndpoints" - Not every Cache Provider ships an endpoint, so this can be handled individually
* "flushCacheForUrl($url)" - Use "flushCacheForUrls(array $urls): void" instead

New methods have been introduced:
* "isActive(): bool" to define if a Proxy Cache Provider has been set up properly
* "shouldRequestBeMarkedAsCached(RequestInterface $request): bool" allows to define whether a frontend page is behind a reverse proxy and should be added to the cache

In addition, the interface is now fully typed.

The TYPO3 Extension now required PHP 8.1 and TYPO3 v11 LTS.

0 comments on commit 0b930d2

Please sign in to comment.