From 268f2917f42ee56a81a849c31182e2f062cbc786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kr=C3=A4mer?= Date: Fri, 24 Jan 2025 13:07:12 +0100 Subject: [PATCH] disable cache for EXT:crawler indexing requests --- .../T3CrawlerIndexingProcessListener.php | 21 +++++++++++++++++++ Configuration/Services.yaml | 6 ++++++ Documentation/Configuration/Htaccess.rst | 4 ++++ Documentation/Configuration/Nginx.rst | 5 +++++ 4 files changed, 36 insertions(+) create mode 100644 Classes/Cache/Listener/T3CrawlerIndexingProcessListener.php diff --git a/Classes/Cache/Listener/T3CrawlerIndexingProcessListener.php b/Classes/Cache/Listener/T3CrawlerIndexingProcessListener.php new file mode 100644 index 00000000000..6aaabd33c4c --- /dev/null +++ b/Classes/Cache/Listener/T3CrawlerIndexingProcessListener.php @@ -0,0 +1,21 @@ +getRequest()->hasHeader('X-T3Crawler')) { + $event->addExplanation(__CLASS__, 'T3Crawler Indexing request'); + $event->setSkipProcessing(true); + } + } +} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 121c0ab75de..b9f8c644787 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -52,6 +52,12 @@ services: identifier: 'SolrIndexingProcessListenerFallback' event: SFC\Staticfilecache\Event\CacheRuleFallbackEvent + SFC\Staticfilecache\Cache\Listener\T3CrawlerIndexingProcessListener: + tags: + - name: event.listener + identifier: 'T3CrawlerIndexingProcessListenerFallback' + event: SFC\Staticfilecache\Event\CacheRuleFallbackEvent + SFC\Staticfilecache\Cache\Listener\ValidRequestMethodListener: tags: - name: event.listener diff --git a/Documentation/Configuration/Htaccess.rst b/Documentation/Configuration/Htaccess.rst index fb7c75d038f..33398cb7a34 100755 --- a/Documentation/Configuration/Htaccess.rst +++ b/Documentation/Configuration/Htaccess.rst @@ -31,6 +31,10 @@ variables (SFC_ROOT, SFC_GZIP) and read the comments carefully. RewriteCond %{HTTP:X-Tx-Solr-Iq} .+ RewriteRule .* - [E=SFC_HOST:invalid-host] + # Disable cache for EXT:crawler indexing requests + RewriteCond %{HTTP:X-T3Crawler} .+ + RewriteRule .* - [E=SFC_HOST:invalid-host] + # Important Note for scheme and port. TYPO3 handle Reverse proxies by respect # X-Forwarded-For headers. The Apache do not know this configuration. If there # is a reverse proxy that e.g. terminate SSL and all requests are "http", please diff --git a/Documentation/Configuration/Nginx.rst b/Documentation/Configuration/Nginx.rst index 6b316838035..83f8f1aae14 100755 --- a/Documentation/Configuration/Nginx.rst +++ b/Documentation/Configuration/Nginx.rst @@ -70,6 +70,11 @@ By the following configuration: return 405; } + # Disable cache for EXT:crawler indexing requests + if ($http_x_t3crawler) { + return 405; + } + charset utf-8; default_type text/html; try_files /typo3temp/assets/tx_staticfilecache/${scheme}_${host}_${server_port}${uri}/index