Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
EsiResponseCacheStrategy.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * This code is partially based on the Rack-Cache library by Ryan Tomayko,
09 * which is released under the MIT license.
10 * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
11 *
12 * For the full copyright and license information, please view the LICENSE
13 * file that was distributed with this source code.
14 */
15
16 namespace Symfony\Component\HttpKernel\HttpCache;
17
18 use Symfony\Component\HttpFoundation\Response;
19
20 /**
21 * EsiResponseCacheStrategy knows how to compute the Response cache HTTP header
22 * based on the different ESI response cache headers.
23 *
24 * This implementation changes the master response TTL to the smallest TTL received
25 * or force validation if one of the ESI has validation cache strategy.
26 *
27 * @author Fabien Potencier <fabien@symfony.com>
28 */
29 class EsiResponseCacheStrategy implements EsiResponseCacheStrategyInterface
30 {
31 private $cacheable = true;
32 private $embeddedResponses = 0;
33 private $ttls = array();
34 private $maxAges = array();
35
36 /**
37 * {@inheritdoc}
38 */
39 public function add(Response $response)
40 {
41 if ($response->isValidateable()) {
42 $this->cacheable = false;
43 } else {
44 $this->ttls[] = $response->getTtl();
45 $this->maxAges[] = $response->getMaxAge();
46 }
47
48 $this->embeddedResponses++;
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function update(Response $response)
55 {
56 // if we have no embedded Response, do nothing
57 if (0 === $this->embeddedResponses) {
58 return;
59 }
60
61 // Remove validation related headers in order to avoid browsers using
62 // their own cache, because some of the response content comes from
63 // at least one embedded response (which likely has a different caching strategy).
64 if ($response->isValidateable()) {
65 $response->setEtag(null);
66 $response->setLastModified(null);
67 $this->cacheable = false;
68 }
69
70 if (!$this->cacheable) {
71 $response->headers->set('Cache-Control', 'no-cache, must-revalidate');
72
73 return;
74 }
75
76 $this->ttls[] = $response->getTtl();
77 $this->maxAges[] = $response->getMaxAge();
78
79 if (null !== $maxAge = min($this->maxAges)) {
80 $response->setSharedMaxAge($maxAge);
81 $response->headers->set('Age', $maxAge - min($this->ttls));
82 }
83 $response->setMaxAge(0);
84 }
85 }
86