4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\HttpCache;
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Component\HttpFoundation\Response;
17 interface SurrogateInterface
20 * Returns surrogate name.
24 public function getName();
27 * Returns a new cache strategy instance.
29 * @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance
31 public function createCacheStrategy();
34 * Checks that at least one surrogate has Surrogate capability.
36 * @param Request $request A Request instance
38 * @return bool true if one surrogate has Surrogate capability, false otherwise
40 public function hasSurrogateCapability(Request $request);
43 * Adds Surrogate-capability to the given Request.
45 * @param Request $request A Request instance
47 public function addSurrogateCapability(Request $request);
50 * Adds HTTP headers to specify that the Response needs to be parsed for Surrogate.
52 * This method only adds an Surrogate HTTP header if the Response has some Surrogate tags.
54 * @param Response $response A Response instance
56 public function addSurrogateControl(Response $response);
59 * Checks that the Response needs to be parsed for Surrogate tags.
61 * @param Response $response A Response instance
63 * @return bool true if the Response needs to be parsed, false otherwise
65 public function needsParsing(Response $response);
68 * Renders a Surrogate tag.
70 * @param string $uri A URI
71 * @param string $alt An alternate URI
72 * @param bool $ignoreErrors Whether to ignore errors or not
73 * @param string $comment A comment to add as an esi:include tag
77 public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '');
80 * Replaces a Response Surrogate tags with the included resource content.
82 * @param Request $request A Request instance
83 * @param Response $response A Response instance
87 public function process(Request $request, Response $response);
90 * Handles a Surrogate from the cache.
92 * @param HttpCache $cache An HttpCache instance
93 * @param string $uri The main URI
94 * @param string $alt An alternative URI
95 * @param bool $ignoreErrors Whether to ignore errors or not
99 * @throws \RuntimeException
102 public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors);