mirror of
https://gitnet.fr/deblan/gist.git
synced 2021-08-14 08:30:49 +02:00
HTTP Cache
This commit is contained in:
parent
2d8f19437a
commit
b7e6d8c69c
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@
|
||||
/app/config/propel/
|
||||
/data/
|
||||
/trans/
|
||||
/cache/
|
||||
|
1
Makefile
1
Makefile
@ -26,6 +26,7 @@ update:
|
||||
|
||||
$(GIT) pull origin master
|
||||
${MKDIR} -p data/git
|
||||
${MKDIR} -p data/cache
|
||||
$(COMPOSER) update
|
||||
$(NPM) install
|
||||
|
||||
|
@ -9,6 +9,6 @@ $app->register(new TwigServiceProvider(), array(
|
||||
$app->extend('twig', function ($twig, $app) {
|
||||
$base = str_replace($app['request']->server->get('SCRIPT_NAME'), '', $app['request']->getBaseUrl());
|
||||
$twig->addGlobal('web_path', $base.'/');
|
||||
|
||||
|
||||
return $twig;
|
||||
});
|
||||
|
7
app/bootstrap.php.d/80-cache.php
Normal file
7
app/bootstrap.php.d/80-cache.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Silex\Provider\HttpCacheServiceProvider;
|
||||
|
||||
$app->register(new HttpCacheServiceProvider(), array(
|
||||
'http_cache.cache_dir' => $app['root_path'].'/cache/',
|
||||
));
|
@ -175,9 +175,17 @@ abstract class Controller
|
||||
$params['user'] = $this->getUser();
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
$body = $app['twig']->render(
|
||||
$template,
|
||||
$params
|
||||
);
|
||||
|
||||
$response = new Response($body);
|
||||
|
||||
if (empty($params['no_cache'])) {
|
||||
$response->setTtl(3600 * 24 * 7);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ $app = require __DIR__.'/../app/bootstrap.php';
|
||||
|
||||
$app['env'] = 'prod';
|
||||
|
||||
$app->run();
|
||||
$app['http_cache']->run();
|
||||
|
Loading…
Reference in New Issue
Block a user