File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace SFC \Staticfilecache \Middleware ;
6
+
7
+ use Psr \Http \Message \ResponseInterface ;
8
+ use Psr \Http \Message \ServerRequestInterface ;
9
+ use Psr \Http \Server \MiddlewareInterface ;
10
+ use Psr \Http \Server \RequestHandlerInterface ;
11
+ use TYPO3 \CMS \Frontend \Cache \CacheInstruction ;
12
+
13
+ class FrontendCacheMiddleware implements MiddlewareInterface
14
+ {
15
+ public function process (
16
+ ServerRequestInterface $ request ,
17
+ RequestHandlerInterface $ handler ,
18
+ ): ResponseInterface
19
+ {
20
+ if (class_exists (CacheInstruction::class)) {
21
+ // Get the attribute, if not available, use a new CacheInstruction object
22
+ $ cacheInstruction = $ request ->getAttribute (
23
+ 'frontend.cache.instruction ' ,
24
+ new CacheInstruction (),
25
+ );
26
+
27
+ // Disable the cache and give a reason
28
+ $ cacheInstruction ->disableCache ('EXT:staticfilecache: Cache is disabled ' );
29
+
30
+ // Write back the cache instruction to the attribute
31
+ $ request = $ request ->withAttribute ('frontend.cache.instruction ' , $ cacheInstruction );
32
+ }
33
+ return $ handler ->handle ($ request );
34
+ }
35
+ }
Original file line number Diff line number Diff line change 5
5
use SFC \Staticfilecache \Middleware \CookieCheckMiddleware ;
6
6
use SFC \Staticfilecache \Middleware \FallbackMiddleware ;
7
7
use SFC \Staticfilecache \Middleware \FrontendUserMiddleware ;
8
+ use SFC \Staticfilecache \Middleware \FrontendCacheMiddleware ;
8
9
use SFC \Staticfilecache \Middleware \GenerateMiddleware ;
9
10
use SFC \Staticfilecache \Middleware \PrepareMiddleware ;
10
11
40
41
'staticfilecache/generate ' ,
41
42
],
42
43
],
44
+ 'staticfilecache/frontend-cache ' => [
45
+ 'target ' => FrontendCacheMiddleware::class,
46
+ 'after ' => [
47
+ 'typo3/cms-frontend/authentication ' ,
48
+ ],
49
+ 'before ' => [
50
+ 'staticfilecache/generate ' ,
51
+ ],
52
+ ],
43
53
'staticfilecache/cookie-check ' => [
44
54
'target ' => CookieCheckMiddleware::class,
45
55
'before ' => [
You can’t perform that action at this time.
0 commit comments