1 | <?php |
||
13 | class Expire |
||
14 | { |
||
15 | private $expires = [ |
||
16 | 'text/css' => '+1 year', |
||
17 | 'application/atom+xml' => '+1 hour', |
||
18 | 'application/rdf+xml' => '+1 hour', |
||
19 | 'application/rss+xml' => '+1 hour', |
||
20 | 'application/json' => '+0 seconds', |
||
21 | 'application/ld+json' => '+0 seconds', |
||
22 | 'application/schema+json' => '+0 seconds', |
||
23 | 'application/vnd.geo+json' => '+0 seconds', |
||
24 | 'application/xml' => '+0 seconds', |
||
25 | 'text/xml' => '+0 seconds', |
||
26 | 'image/vnd.microsoft.icon' => '+1 week', |
||
27 | 'image/x-icon' => '+1 week', |
||
28 | 'text/html' => '+0 seconds', |
||
29 | 'application/javascript' => '+1 year', |
||
30 | 'application/x-javascript' => '+1 year', |
||
31 | 'text/javascript' => '+1 year', |
||
32 | 'application/manifest+json' => '+1 week', |
||
33 | 'application/x-web-app-manifest+json' => '+0 seconds', |
||
34 | 'text/cache-manifest' => '+0 seconds', |
||
35 | 'audio/ogg' => '+1 month', |
||
36 | 'image/bmp' => '+1 month', |
||
37 | 'image/gif' => '+1 month', |
||
38 | 'image/jpeg' => '+1 month', |
||
39 | 'image/png' => '+1 month', |
||
40 | 'image/svg+xml' => '+1 month', |
||
41 | 'image/webp' => '+1 month', |
||
42 | 'video/mp4' => '+1 month', |
||
43 | 'video/ogg' => '+1 month', |
||
44 | 'video/webm' => '+1 month', |
||
45 | 'application/vnd.ms-fontobject' => '+1 month', |
||
46 | 'font/eot' => '+1 month', |
||
47 | 'font/opentype' => '+1 month', |
||
48 | 'application/x-font-ttf' => '+1 month', |
||
49 | 'application/font-woff' => '+1 month', |
||
50 | 'application/x-font-woff' => '+1 month', |
||
51 | 'font/woff' => '+1 month', |
||
52 | 'application/font-woff2' => '+1 month', |
||
53 | 'text/x-cross-domain-policy' => '+1 week', |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * Add a new expire. |
||
58 | * |
||
59 | * @param string $mime |
||
60 | * @param string $expire |
||
61 | */ |
||
62 | public function addExpire($mime, $expire) |
||
66 | |||
67 | /** |
||
68 | * Execute the middleware. |
||
69 | * |
||
70 | * @param RequestInterface $request |
||
71 | * @param ResponseInterface $response |
||
72 | * @param callable $next |
||
73 | * |
||
74 | * @return ResponseInterface |
||
75 | */ |
||
76 | public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next) |
||
98 | } |
||
99 |