Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable cache for EXT:crawler indexing requests #429

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Classes/Cache/Listener/T3CrawlerIndexingProcessListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace SFC\Staticfilecache\Cache\Listener;

use SFC\Staticfilecache\Event\CacheRuleFallbackEvent;

/**
* T3Crawler Indexing process.
*/
class T3CrawlerIndexingProcessListener
{
public function __invoke(CacheRuleFallbackEvent $event): void
{
if ($event->getRequest()->hasHeader('X-T3Crawler')) {
$event->addExplanation(__CLASS__, 'T3Crawler Indexing request');
$event->setSkipProcessing(true);
}
}
}
6 changes: 6 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Documentation/Configuration/Htaccess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Documentation/Configuration/Nginx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading