@@ -22,25 +22,6 @@ public function __invoke(Request $request): Response
22
22
$ format = $ request ->get ('format ' );
23
23
$ noproxy = $ request ->get ('_noproxy ' );
24
24
25
- $ cacheKey = 'http_ ' . json_encode ($ request ->toArray ());
26
- /** @var Response $cachedResponse */
27
- $ cachedResponse = $ this ->cache ->get ($ cacheKey );
28
- if ($ cachedResponse ) {
29
- $ ifModifiedSince = $ request ->server ('HTTP_IF_MODIFIED_SINCE ' );
30
- $ lastModified = $ cachedResponse ->getHeader ('last-modified ' );
31
- if ($ ifModifiedSince && $ lastModified ) {
32
- $ lastModified = new \DateTimeImmutable ($ lastModified );
33
- $ lastModifiedTimestamp = $ lastModified ->getTimestamp ();
34
- $ modifiedSince = strtotime ($ ifModifiedSince );
35
- // TODO: \DateTimeImmutable can be compared directly
36
- if ($ lastModifiedTimestamp <= $ modifiedSince ) {
37
- $ modificationTimeGMT = gmdate ('D, d M Y H:i:s ' , $ lastModifiedTimestamp );
38
- return new Response ('' , 304 , ['last-modified ' => $ modificationTimeGMT . 'GMT ' ]);
39
- }
40
- }
41
- return $ cachedResponse ->withHeader ('rss-bridge ' , 'This is a cached response ' );
42
- }
43
-
44
25
if (!$ bridgeName ) {
45
26
return new Response (render (__DIR__ . '/../templates/error.html.php ' , ['message ' => 'Missing bridge parameter ' ]), 400 );
46
27
}
@@ -66,6 +47,8 @@ public function __invoke(Request $request): Response
66
47
define ('NOPROXY ' , true );
67
48
}
68
49
50
+ $ cacheKey = 'http_ ' . json_encode ($ request ->toArray ());
51
+
69
52
$ bridge = $ this ->bridgeFactory ->create ($ bridgeClassName );
70
53
71
54
$ response = $ this ->createResponse ($ request , $ bridge , $ format );
@@ -80,21 +63,6 @@ public function __invoke(Request $request): Response
80
63
$ this ->cache ->set ($ cacheKey , $ response , $ ttl );
81
64
}
82
65
83
- if (in_array ($ response ->getCode (), [403 , 429 , 503 ])) {
84
- // Cache these responses for about ~20 mins on average
85
- $ this ->cache ->set ($ cacheKey , $ response , 60 * 15 + rand (1 , 60 * 10 ));
86
- }
87
-
88
- if ($ response ->getCode () === 500 ) {
89
- $ this ->cache ->set ($ cacheKey , $ response , 60 * 15 );
90
- }
91
-
92
- // For 1% of requests, prune cache
93
- if (rand (1 , 100 ) === 1 ) {
94
- // This might be resource intensive!
95
- $ this ->cache ->prune ();
96
- }
97
-
98
66
return $ response ;
99
67
}
100
68
0 commit comments