Skip to content

Instantly share code, notes, and snippets.

@mtymek
mtymek / Benchmark for isValid
Last active August 29, 2015 14:22
HeaderSecurity benchmark
<?php
include 'vendor/autoload.php';
$ts = microtime(true);
for ($i = 0; $i < 20000; $i++) {
$request = \Zend\Diactoros\ServerRequestFactory::fromGlobals();
}
@mtymek
mtymek / CachingMiddleware.php
Last active August 30, 2015 17:19
CachingMiddleware
<?php
class CachingMiddleware
{
protected $cacheDir = 'data/cache/pages';
protected function getCacheFile(RequestInterface $request)
{
$uri = $request->getUri();
return 'cached-'