mirror of
https://gitnet.fr/deblan/gist.git
synced 2021-08-14 08:30:49 +02:00
Cache control
This commit is contained in:
parent
b7e6d8c69c
commit
2ac9737409
@ -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,
|
||||
));
|
||||
|
@ -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'])) {
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user