dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxContentMediaCache_contract_test.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4$root = dirname(__DIR__, 3);
5
6$responseFile = $root . '/dbx/modules/dbxContent/include/dbxContentMediaResponse.class.php';
7$fallbackFile = $root . '/dbx/modules/dbxContent/dbxContent.class.php';
8$response = file_get_contents($responseFile);
9$fallback = file_get_contents($fallbackFile);
10
11if (!is_string($response) || !is_string($fallback)) {
12 throw new RuntimeException('Die dbxContent-Medienklassen konnten nicht gelesen werden.');
13}
14
15foreach (array(
16 "header('ETag: ' . \$etag)",
17 "header('Last-Modified: ' . \$lastModified)",
18 "header('Cache-Control: private, no-cache')",
19 'HTTP_IF_NONE_MATCH',
20 'HTTP_IF_MODIFIED_SINCE',
21) as $needle) {
22 if (!str_contains($response, $needle)) {
23 throw new RuntimeException('Der Medien-Cache-Vertrag fehlt: ' . $needle);
24 }
25}
26
27if (str_contains($response, 'max-age=3600')
28 || str_contains($fallback, 'max-age=31536000, immutable')
29 || substr_count($fallback, "header('Cache-Control: private, no-cache')") < 2) {
30 throw new RuntimeException('Aktualisierte Medien dürfen nicht unter unveränderter ID veralten.');
31}
32
33echo "OK dbxContent media responses revalidate changed files with ETag and Last-Modified\n";