diff --git a/app/bootstrap.php.d/80-cache.php b/app/bootstrap.php.d/80-cache.php index 3013cd6..3a28362 100644 --- a/app/bootstrap.php.d/80-cache.php +++ b/app/bootstrap.php.d/80-cache.php @@ -4,4 +4,5 @@ use Silex\Provider\HttpCacheServiceProvider; $app->register(new HttpCacheServiceProvider(), array( 'http_cache.cache_dir' => $app['root_path'].'/cache/', + 'http_cache.esi' => null, )); diff --git a/src/Gist/Controller/Controller.php b/src/Gist/Controller/Controller.php index 7cbcccd..b77fa11 100644 --- a/src/Gist/Controller/Controller.php +++ b/src/Gist/Controller/Controller.php @@ -136,7 +136,6 @@ abstract class Controller $app = $this->getApp(); if (!empty($request)) { - } $securityContext = $app['security.token_storage']; @@ -160,10 +159,11 @@ abstract class Controller * * @param string $template * @param array $params + * @param bool $renderResponse * * @return string */ - public function render($template, array $params = null) + public function render($template, array $params = null, $renderResponse = true) { $app = $this->getApp(); @@ -180,6 +180,10 @@ abstract class Controller $params ); + if (!$renderResponse) { + return $body; + } + $response = new Response($body); if (empty($params['no_cache'])) { diff --git a/src/Gist/Controller/EditController.php b/src/Gist/Controller/EditController.php index 1767dce..cc7271f 100644 --- a/src/Gist/Controller/EditController.php +++ b/src/Gist/Controller/EditController.php @@ -9,6 +9,7 @@ use Gist\Model\Gist; use GitWrapper\GitException; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Form\FormError; +use Symfony\Component\HttpFoundation\Response; /** * Class EditController. @@ -22,7 +23,7 @@ class EditController extends Controller * * @param Request $request * - * @return string + * @return Response */ public function createAction(Request $request) { @@ -68,7 +69,7 @@ class EditController extends Controller * * @param Request $request * - * @return string + * @return Response */ public function cloneAction(Request $request, $gist, $commit) { diff --git a/src/Gist/Controller/LoginController.php b/src/Gist/Controller/LoginController.php index f835306..5547be3 100644 --- a/src/Gist/Controller/LoginController.php +++ b/src/Gist/Controller/LoginController.php @@ -20,7 +20,7 @@ class LoginController extends Controller * * @param Request $request * - * @return string + * @return Response */ public function registerAction(Request $request) { @@ -72,7 +72,7 @@ class LoginController extends Controller * * @param Request $request * - * @return string + * @return Response */ public function loginAction(Request $request) { diff --git a/src/Gist/Controller/MyController.php b/src/Gist/Controller/MyController.php index d59f315..9b4a170 100644 --- a/src/Gist/Controller/MyController.php +++ b/src/Gist/Controller/MyController.php @@ -7,6 +7,7 @@ use Gist\Form\DeleteGistForm; use Gist\Form\FilterGistForm; use Gist\Form\UserPasswordForm; use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Response; /** * Class MyController. @@ -21,7 +22,7 @@ class MyController extends Controller * @param Request $request * @param int $page * - * @return string + * @return Response */ public function myAction(Request $request, $page) { diff --git a/src/Gist/Controller/ViewController.php b/src/Gist/Controller/ViewController.php index 44aeedc..d80d3b3 100644 --- a/src/Gist/Controller/ViewController.php +++ b/src/Gist/Controller/ViewController.php @@ -66,14 +66,14 @@ class ViewController extends Controller * @param string $gist Gist's ID * @param string $commit The commit * - * @return string|Response + * @return Response */ public function embedJsAction(Request $request, $gist, $commit) { $viewOptions = $this->getViewOptions($request, $gist, $commit); return new Response( - $this->render('View/embedJs.html.twig', $viewOptions), + $this->render('View/embedJs.html.twig', $viewOptions, false), 200, array( 'Content-Type' => 'text/javascript', @@ -88,7 +88,7 @@ class ViewController extends Controller * @param string $gist Gist's ID * @param string $commit The commit * - * @return string|Response + * @return Response */ public function rawAction(Request $request, $gist, $commit) { @@ -114,7 +114,7 @@ class ViewController extends Controller * @param string $gist Gist's ID * @param string $commit The commit * - * @return string|Response + * @return Response */ public function downloadAction(Request $request, $gist, $commit) { @@ -133,7 +133,8 @@ class ViewController extends Controller 'Content-Disposition' => sprintf('filename=%s.%s', $gist->getFile(), $gist->getTypeAsExtension()), 'Content-Length' => mb_strlen($viewOptions['raw_content']), 'Content-Type' => 'application/force-download', - ) + ), + false ); } else { return $this->notFoundResponse($app); @@ -146,7 +147,7 @@ class ViewController extends Controller * @param Request $request * @param string $gist Gist's ID * - * @return string|Response + * @return Response */ public function revisionsAction(Request $request, $gist) {