Nginx Connector

Extension key:nginx_connector
Authors:Alexander Nitsche
License:Open Content License available from
Rendered:2021-07-22 17:55 GMT

This extension provides an Nginx cache connector which purges cached responses in Nginx along with cached pages in TYPO3.


  1. Configurable Nginx base url
  2. Sends PURGE {Nginx base url}/* when flushing the frontend or all caches in the TYPO3 backend.
  3. Sends PURGE {Nginx request url} for all cached responses associated with a page when flushing its page cache in the TYPO3 backend.
  4. Detects and handles failed Nginx purge requests.

Out of Scope

  • Nginx: Handling of incoming PURGE requests
  • Nginx: Deleting of cached responses

The handling of cache purges on Nginx side can be managed by the non-free, commercial Nginx module ngx_cache_purge or by a custom implementation, for example this Perl implementation – Perl scripts are supported by Nginx natively.

Technical Background

The Nginx cache can be used to cache responses from the TYPO3 frontend and thus to reduce server load significantly. The creation and lifetime of cache entries depend on the TYPO3 response headers ETag, Cache-Control and Expires which are emitted if the TYPO3 configuration property config.sendCacheHeaders is set. The cache entries are file based and have the hashed request url as filename. Now in order to enable TYPO3 to flush the Nginx cache along with its own, this extension stores the request url whenever TYPO3 is serving a cached page and links it to the cached page. As soon as the cache of that page should be cleared, this extension sends a purge request to Nginx for every linked request url.

TYPO3 extension nginx_connector processing

TYPO3 extensions nginx_connector vs. nginx_cache

This extension is based mainly on the architecture of the TYPO3 extension nginx_cache but its implementation tries to be as clean and as close as possible to the TYPO3 Core. Some differences are:

  • improved handling of multiple purge requests
  • smarter handling of failed purge requests
  • calculating less but re-using more TYPO3 core cache params
  • use sending of cache headers by TYPO3 core instead of custom implementation, e.g. caching of request urls with url queries is supported
  • Nginx base url is configurable in order to support flushing caches from commandline

Nginx Cache vs. Varnish Cache

Other caches like Varnish Cache offer a query language to purge cached responses by meta data like headers. This can be used to link a TYPO3 cached page to a Varnish cached response by sending the page id in a custom header of the TYPO3 response and then send this page id with the purge request too - see TYPO3 extension varnish for inspiration. The Nginx cache unfortunately does not provide this mechanism and thus its handling adds complexity to this extension by managing an own table of links between TYPO3 page cache and Nginx cached responses.

On the other side using the Nginx cache gives the advantage of using a combined web server and cache instance instead of having to manage an additional cache server. The performance of both caches should be almost the same according to various benchmarks in the world wide web.