Пример #1
0
 /**
  * Cache the response 1 year (31536000 sec)
  */
 protected function cacheResponse(Response $response)
 {
     $response->setSharedMaxAge(31536000);
     $response->setMaxAge(31536000);
     $response->setExpires(new \DateTime('+1 year'));
     return $response;
 }
Пример #2
0
 public static function get($file = null)
 {
     $directory = env('DJEM_DEBUG', false) ? 'panel' : 'panel-compiled';
     if (empty($file)) {
         $file = 'index.html';
     }
     $public = realpath(__DIR__ . '/../../../' . $directory);
     $file = realpath($public . '/' . preg_replace('|[^-_0-9a-z/.]|i', '', $file));
     if (!is_file($file) || substr($file, 0, strlen($public)) !== $public) {
         abort(404);
     }
     // @codeCoverageIgnore
     $response = new Response(file_get_contents($file), 200, ['Content-type' => self::getContentType($file)]);
     $response->setSharedMaxAge(3600);
     $response->setMaxAge(3600);
     $response->setExpires(new \DateTime('+1 hour'));
     return $response;
 }